DevOps Manual Set up - Set 1 Flashcards
What does the mvn package
command do in your project directory from the terminal?
Compiles the source code, runs tests, and packages the project, creating a distributable JAR or WAR file based on the project configuration in Maven.
mvn package
generates the initial artifact.
What is Spring Boot Maven Plugin?
The Spring Boot Maven Plugin simplifies building and running Spring Boot applications, handling tasks like packaging, running, and creating executable JARs.
This plugin automates many configuration steps, simplifying the development and deployment of Spring Boot projects within the Maven ecosystem.
What does the repackage
goal from Spring Boot Maven Plugin do?
The “repackage” goal changes an existing JAR or WAR by embedding dependencies.
repackage
modifies or enhances an existing artifact.
It creates a self-contained executable artifact. This executable artifact can be run directly without requiring external dependencies.
What does the mvn clean
command do in your project directory from the terminal?
The mvn clean command removes the generated build artifacts and cleans the project directory, erasing compiled classes, resources, and temporary build files, ensuring a fresh build.
How to start a spring boot application using the .jar
file on the terminal?
java -jar target/[name of the jar file].jar
What is the purpose of Maven Surefire Plugin?
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates detailed reports and ensuring code stability.
Generates two file formats:
- Plain text files *.txt
- XML files *.xml
Default: Files are generated in ${basedir}/target/surefire-reports/TEST-*.xml.
How to isolate unit tests with maven-surefire-plugin and why?
Exclude integration tests by targeting the project naming convention for integration tests:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IntegrationTest</exclude>
</excludes>
</configuration>
</plugin>
Excluding integration tests from Surefire Plugin speeds up unit testing feedback, isolates unit testing, and avoids dependencies (external systems, databases, or services), enhancing agile development cycles.
In a Spring Boot application using the spring-boot-starter-parent, how do you package the application as an executable JAR with all its dependencies?
spring-boot-maven-plugin is included in the spring-boot-starter-parent in your pom.xml. Running mvn package
will then produce an executable JAR with embedded dependencies.
What is the purpose of Maven Failsafe Plugin?
Maven Failsafe Plugin runs integration tests (e.g., database, server) in a separate phase, ensuring application components work together, validating real-world functionality without interfering with unit tests during the build.
In which phase of the build lifecyle, unit and integration tests are run?
Unit tests are run in the test
phase.
Integration tests are run by default by Maven Failsafe Plugin during the integration-test
phase, before the verify
phase.
How many phases are there in the Maven lifecycle for running integration tests?
1) pre-integration-test
2) integration-test
3) post-integration-test
4) verify
Which plugins and configurations are necessary for setting up integration tests in a Spring Boot application?
- Build helper within spring-boot-maven-plugin: Configure a random port for the server during integration tests.
- Also within spring-boot-maven-plugin: Starts/stops the application before and after integration tests.
- Within maven-surefire-plugin: Excludes integration tests during the unit test phase.
- Within maven-failsafe-plugin: Configures and runs the actual integration tests.
What is Docker?
- Platform for building, running and shipping applications
- Developers can easily build and deploy applications running in containers
- Local development is the same across any environment
- Used a lot in CI/CD workflows
What are Virtual Machines?
Virtual Machines (VMs) are software emulations of physical computers. They run operating systems and applications, creating isolated environments within a host system, enabling multiple OS instances on a single hardware system.
Virtual machines are running on and sharing resources with a physical computer, which is called the host. The host system provides the resources (like CPU, memory, storage) and environment for these virtual machines to operate.