This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Unzip the Fat JAR | |
| RUN mkdir -p target/extracted && \ | |
| java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted | |
| # Copy layers individually for maximum caching | |
| COPY --from=build /app/target/extracted/dependencies/ ./ | |
| COPY --from=build /app/target/extracted/spring-boot-loader/ ./ | |
| COPY --from=build /app/target/extracted/application/ ./ | |
| ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebMvcTest(ProductController.class) | |
| class ProductControllerTest { | |
| @Autowired | |
| private MockMvc mockMvc; | |
| @MockBean | |
| private ProductService productService; // Service must be mocked in a slice test | |
| @Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Testcontainers | |
| @SpringBootTest | |
| class MyIntegrationTest { | |
| @Container | |
| @ServiceConnection | |
| static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine"); | |
| @Test | |
| void testDatabaseLogic() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebMvcTest(UserController.class) | |
| class UserControllerTest { | |
| @Autowired | |
| private MockMvc mockMvc; | |
| @MockBean | |
| private UserService userService; // This mock is injected into UserController | |
| @Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
| class MyIntegrationTest { | |
| @Autowired | |
| private WebTestClient webTestClient; | |
| @Test | |
| void testHelloWorldEndpoint() { | |
| webTestClient.get().uri("/api/hello") | |
| .exchange() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies { | |
| developmentOnly 'org.springframework.boot:spring-boot-devtools' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <dependency> | |
| <groupId>org.springframework.boot</groupId> | |
| <artifactId>spring-boot-devtools</artifactId> | |
| <optional>true</optional> | |
| </dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server: | |
| shutdown: graceful | |
| spring: | |
| lifecycle: | |
| timeout-per-shutdown-phase: 30s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| databaseChangeLog: | |
| - changeSet: | |
| id: 1 | |
| author: gemini | |
| changes: | |
| - createTable: | |
| tableName: users | |
| columns: | |
| - column: | |
| name: id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE users ( | |
| id BIGINT PRIMARY KEY, | |
| username VARCHAR(255) NOT NULL | |
| ); |
NewerOlder