Filter
Exclude
Time range
-
Near
Spring Bootのテストコードを網羅したZennの大全記事が、SI現場の引き継ぎ資料に使える粒度だった。Mockitoだけでなく、SpringBootTestのスライス分割やTestcontainers連携まで踏み込んでいる。テスト戦略を組み直す前に通読しておきたい。 zenn.dev/zak4132/articles/ja…
8
📣 Deal of the Day 📣 Mar 27 HALF OFF NEW MEAP! Testing Spring Boot Applications & selected titles: hubs.la/Q048FMyJ0 Testing concepts, techniques, and tools to deliver quality Spring Boot applications every time. Author and Spring team member Daniel Garnier-Moiroux helps you build a solid mental model of what’s happening in your Spring Boot test suite. #SpringBoot #SpringBootTest #MockMvcTester #SpringExtension #testing #springframework #java #apps You'll learn how to organize fast, reliable, and predictive testing pipelines, test web applications at the API and browser levels, and reliably validate the configuration, binding logic, and properties of Spring Boot applications. You’ll move past the “fire and forget” mindset and discover repeatable steps to manage changing dependencies, simplify your workflow, and eliminate ineffective or broken tests.
1
5
24
1,256
Spring Boot testing goes way beyond @SpringBootTest. To build fast, reliable test suites, you need to understand slice tests, context management, lifecycles, and how @springcentral fits into the broader testing ecosystem. Testing Spring Boot Applications by Daniel Garnier-Moiroux breaks down how it all actually works, so you can test with intent, not guesswork. New in MEAP and half off through March 31st: hubs.la/Q047qxrY0
4
6
714
How to warm up caches in Spring Boot? Or generally do something at the start of a Spring boot application? Usually, such operations are done in the PostConstruct method or by catching the ApplicationReadyEvent event. But there's a significant downside to these options. If the "warming up" is in the PostConstruct, how to disable it in tests? You can add a flag, create a subclass, and replace it in the test config, but this doesn't always help and often looks like a workaround. [A more elegant way to "warm up caches"]: Look, SpringApplication.run(...) returns a fully ready context. You can retrieve a component from it and call the necessary "warming up" method. The code looks like the one in the image: [Advantage]: In integration tests with @SpringBootTest, the main method doesn't run. Consequently, the code inside it doesn't execute. There are no workarounds around PostConstruct, everything is clean and beautiful When a 'warm-up' is still needed in the tests, we add the parameter 'use main method': @SpringBootTest(useMainMethod = SpringBootTest.UseMainMethod.ALWAYS)
8
92
3,701
Java Development Roadmap (Complete Guide) PHASE 1: JAVA FUNDAMENTALS ├── Core Java Basics │ ├── JDK, JRE, JVM architecture │ ├── Data types and variables │ ├── Operators and expressions │ ├── Control flow (if-else, switch, loops) │ └── Arrays and enhanced for loops ├── Object-Oriented Programming │ ├── Classes and objects │ ├── Constructors and this keyword │ ├── Inheritance (extends, super) │ ├── Polymorphism (overloading, overriding) │ ├── Abstraction (abstract classes, interfaces) │ └── Encapsulation (access modifiers) ├── Basic Java APIs │ ├── String, StringBuilder, StringBuffer │ ├── Wrapper classes and autoboxing │ ├── Math, Random, Scanner classes │ └── Date and Time API (java.time) PHASE 2: ADVANCED JAVA ├── Collections Framework │ ├── List (ArrayList, LinkedList, Vector) │ ├── Set (HashSet, LinkedHashSet, TreeSet) │ ├── Queue (PriorityQueue, ArrayDeque) │ ├── Map (HashMap, LinkedHashMap, TreeMap) │ ├── Comparable vs Comparator │ └── Stream operations and lambda expressions ├── Exception Handling │ ├── Checked vs unchecked exceptions │ ├── try-catch-finally blocks │ ├── try-with-resources │ └── Custom exceptions ├── Multithreading │ ├── Thread class and Runnable interface │ ├── Thread lifecycle and states │ ├── Synchronization and locks │ ├── ExecutorService and thread pools │ ├── CompletableFuture for async programming │ └── Concurrent collections ├── File I/O and NIO │ ├── FileReader/FileWriter │ ├── BufferedReader/BufferedWriter │ ├── NIO package (Path, Files) │ └── Serialization PHASE 3: DATABASE & JDBC ├── SQL Fundamentals │ ├── CRUD operations │ ├── Joins (INNER, LEFT, RIGHT, FULL) │ ├── Group By and Having │ ├── Subqueries and set operations │ └── Indexes and performance ├── JDBC Programming │ ├── DriverManager and Connection │ ├── Statement, PreparedStatement │ ├── ResultSet and RowSet │ ├── Batch processing │ ├── Transaction management │ └── Connection pooling (HikariCP) ├── Database Design │ ├── Normalization (1NF to 3NF) │ ├── Primary/Foreign keys │ └── Entity relationship modeling PHASE 4: ENTERPRISE JAVA (JAKARTA EE) ├── Servlet & JSP │ ├── Servlet lifecycle │ ├── RequestDispatcher and sendRedirect │ ├── Session management │ ├── Filters and Listeners │ ├── JSP tags and EL │ └── MVC architecture with Servlets/JSP ├── RESTful Web Services │ ├── JAX-RS (Jersey, RESTEasy) │ ├── @Path, @GET, @POST annotations │ ├── JSON binding with Jackson │ ├── Exception mappers │ └── API documentation (Swagger/OpenAPI) ├── Enterprise Integration │ ├── JMS with ActiveMQ │ ├── EJB basics (stateless, stateful) │ └── JTA transactions PHASE 5: SPRING FRAMEWORK ├── Spring Core │ ├── IoC and Dependency Injection │ ├── ApplicationContext and BeanFactory │ ├── XML vs Java configuration │ ├── Annotations (@Component, @Autowired) │ ├── Bean scopes and lifecycle │ └── Spring Expression Language (SpEL) ├── Spring MVC │ ├── DispatcherServlet workflow │ ├── Controllers (@Controller, @RestController) │ ├── Request mapping and data binding │ ├── Validation with Hibernate Validator │ ├── File upload/download │ └── Interceptors and exception handling ├── Spring Data JPA │ ├── Hibernate ORM fundamentals │ ├── Entity mappings (@OneToMany, @ManyToOne) │ ├── Repository pattern (JpaRepository) │ ├── Query methods and @Query │ ├── Pagination and sorting │ └── Auditing and soft deletes ├── Spring Security │ ├── Authentication and Authorization │ ├── UserDetailsService and JWT │ ├── OAuth2 and SSO integration │ ├── Method-level security │ └── CSRF and CORS configuration PHASE 6: SPRING BOOT & MICROSERVICES ├── Spring Boot Fundamentals │ ├── Auto-configuration │ ├── Starters and dependencies │ ├── application.properties/yml │ ├── Profiles and environment-specific config │ ├── Actuator endpoints │ └── Spring Boot DevTools ├── Microservices Architecture │ ├── Spring Cloud ecosystem │ ├── Service discovery (Eureka) │ ├── API Gateway (Spring Cloud Gateway) │ ├── Circuit breaker (Resilience4j) │ ├── Distributed tracing (Sleuth Zipkin) │ └── Configuration server (Spring Cloud Config) ├── Communication Protocols │ ├── RESTful services with WebClient │ ├── gRPC with Protocol Buffers │ ├── Apache Kafka for event-driven architecture │ └── RabbitMQ with Spring AMQP PHASE 7: BUILD TOOLS & TESTING ├── Build Tools │ ├── Maven (POM.xml, dependencies, plugins) │ │ ├── Project structure │ │ ├── Lifecycle phases │ │ └── Multi-module projects │ ├── Gradle (build.gradle, tasks) │ │ ├── Groovy vs Kotlin DSL │ │ └── Dependency management ├── Testing │ ├── Unit Testing with JUnit 5 │ │ ├── @Test, assertions │ │ ├── Parameterized tests │ │ └── Test lifecycle hooks │ ├── Mocking with Mockito │ │ ├── @Mock, @InjectMocks │ │ └── When/Then patterns │ ├── Integration Testing │ │ ├── @SpringBootTest │ │ ├── TestContainers for database testing │ │ └── @DataJpaTest, @WebMvcTest │ └── Performance Testing (JMeter, Gatling) PHASE 8: DEVOPS & DEPLOYMENT ├── Containerization │ ├── Docker for Java apps │ │ ├── Multi-stage Dockerfiles │ │ ├── JVM optimization in containers │ │ └── Docker Compose for local dev │ ├── Kubernetes for Java microservices │ │ ├── Pod and Service definitions │ │ ├── ConfigMaps and Secrets │ │ └── Helm charts for Java apps ├── CI/CD Pipeline │ ├── Jenkins with Java projects │ ├── GitHub Actions for Spring Boot │ ├── GitLab CI with Maven/Gradle │ └── SonarQube for code quality ├── Cloud Deployment │ ├── AWS (Elastic Beanstalk, ECS, EKS) │ ├── Azure (App Service, AKS) │ ├── Google Cloud (App Engine, GKE) │ └── Heroku / Railway / Render PHASE 9: PERFORMANCE & SECURITY ├── Performance Optimization │ ├── JVM tuning (Heap, GC algorithms) │ ├── Profiling tools (JProfiler, VisualVM) │ ├── Database query optimization │ ├── Caching (Spring Cache, Redis, Hazelcast) │ └── Connection pooling tuning ├── Security Best Practices │ ├── OWASP Top 10 for Java │ ├── Input validation and sanitization │ ├── SQL/NoSQL injection prevention │ ├── Secure coding guidelines │ ├── Dependency scanning (OWASP Dependency Check) │ └── Secret management (Vault, AWS Secrets Manager) PHASE 10: MODERN JAVA & TRENDS ├── Java 8 Features │ ├── Lambda expressions and Streams │ ├── Optional class │ ├── Default and static methods in interfaces │ ├── New Date/Time API │ └── CompletableFuture ├── Java 9-21 Features │ ├── Module system (Project Jigsaw) │ ├── Local variable type inference (var) │ ├── Switch expressions │ ├── Text blocks │ ├── Records and sealed classes │ ├── Pattern matching │ ├── Virtual threads (Project Loom) │ └── Foreign Function & Memory API ├── Reactive Programming │ ├── Project Reactor (Mono, Flux) │ ├── Spring WebFlux │ └── RSocket protocol SPECIALIZED DOMAINS ├── Big Data Java │ ├── Apache Spark with Java │ ├── Apache Flink │ └── Hadoop ecosystem ├── Android Development │ ├── Android SDK with Java │ └── Kotlin interop ├── FinTech/Enterprise │ ├── High-performance Java │ ├── Low-latency systems │ └── Financial messaging (FIX protocol) PROJECTS TO BUILD 1. Beginner: Library Management System (Core Java File I/O) 2. Intermediate: E-commerce API (Spring Boot JPA Security) 3. Intermediate: Task Management App with JWT authentication 4. Advanced: Microservices-based Banking System (Spring Cloud, Kafka) 5. Advanced: Real-time Chat Application (WebSocket STOMP) 6. Expert: Stock Trading Platform (low-latency, reactive) 7. Expert: Scalable Social Media Backend (microservices, Redis) LEARNING RESOURCES ├── Official Documentation │ ├── docs.oracle.com/en/java/ │ ├── spring.io/projects/spring-bo… │ └── hibernate.org/orm/documentat… ├── Books │ ├── "Effective Java" - Joshua Bloch │ ├── "Java Concurrency in Practice" │ ├── "Spring in Action" │ └── "Clean Code" - Robert C. Martin ├── Practice Platforms │ ├── LeetCode (Java problems) │ ├── HackerRank Java track │ ├── CodeWars │ └── Spring Initializr (start.spring.io) RECOMMENDED CERTIFICATIONS ├── Oracle Certified Professional: Java SE Programmer ├── Spring Professional Certification ├── AWS Certified Developer └── Azure Java Developer 📚 RECOMMENDED EBOOK For comprehensive Java and its interview preparation and in-depth concepts, check out: 👉Grab the Java Handbook: codewithdhanian.gumroad.com/…)** This ebook covers: - Core Java fundamentals with detailed explanations - Advanced Java concepts (Multithreading, Collections) - Spring/Spring Boot interview questions - Microservices design patterns - Real-world scenarios and coding problems - 300 frequently asked interview questions - Code examples and best practices - System design for Java developers Estimated Time: 6-12 months for core proficiency, 1-2 years for enterprise readiness Key Principle: Write code daily, understand the "why" behind features, master debugging Progression Strategy: 1. Months 1-3: Core Java OOP concepts 2. Months 4-6: Advanced Java JDBC Basic Servlets 3. Months 7-12: Spring Framework Spring Boot 4. Year 2: Microservices Cloud Advanced topics 5. Year 3 : Specialization Architecture Java Developer Mindset: - Strong typing catches bugs early - JVM is your friend - understand it - Enterprise patterns matter - Backward compatibility is sacred - Verbose can be clear - prioritize readability - Always consider garbage collection and memory - Design for interfaces, not implementations Daily Learning Routine: - Morning: Read Java/Spring documentation or articles - Afternoon: Code implementation - Evening: Code review and optimization - Weekend: Build side projects and experiment Community to Follow: - r/java, r/springsource - Follow @e_opore on X - Java Champions on Twitter - Spring Blog - InfoQ Java section Remember: Java is everywhere - from Android phones to enterprise servers to big data systems. Master the fundamentals first, then explore specialized domains. The ecosystem is vast but well-documented. Build projects that solve real problems, and always keep learning as Java evolves every 6 months now!
9
118
623
20,890
Feb 18
The only Java Spring Boot concepts you need to know • Spring Boot Setup → @ SpringBootApplication, Spring Initializr • Dependency Injection & IoC → @ Autowired, Bean scopes • Auto-configuration & Starters → reduced boilerplate config • REST API Basics → @ RestController, @ GetMapping, @ PostMapping • HTTP Methods & Routing → @ PutMapping, @ DeleteMapping, @ RequestMapping • Request Handling → @ RequestBody, @ PathVariable, @ RequestParam • Configuration → application .properties, application.yml, Spring Profiles • Spring Data JPA → @ Entity, @ Table, @ Id • Repositories → JpaRepository, derived queries & @ Query • Relationships → @ OneToMany, @ ManyToOne, @ JoinColumn • Validation → @ Valid, @ NotNull, @ Size • Exception Handling → @ ControllerAdvice, @ ExceptionHandler • Security Basics → Spring Security setup, roles & permissions • JWT Authentication → token filters & validation • Transactions → @ Transactional • Actuator → app health, metrics & monitoring • Testing → @ SpringBootTest, @ WebMvcTest, unit & integration tests • Caching → @ Cacheable, cache strategies • Logging → structured logs, logging levels • Reactive Support (optional) → WebFlux for non-blocking apps • Build & Packaging → Maven / Gradle, runnable JAR/WAR
40
55
436
16,520
How to warm up caches in Spring Boot? And in general, how to do something at the start of the application? Usually, such operations are done in the PostConstruct method or by catching the ApplicationReadyEvent event. But there's a significant downside to these options. If the "warming up" is in the PostConstruct, how to disable it in tests? You can add a flag, make a subclass, and replace it in the test config, but this doesn't always help and often looks like a workaround. I'll show a more elegant way to "warm up caches". It will definitely come in handy sometime 100% Look, SpringApplication.run(...) returns a fully ready context. You can retrieve a component from it and call the necessary "warming up" method. The code looks like this: @SpringBootApplication public class MainApplication {   public static void main(String[] args) {     ApplicationContext ctx = SpringApplication.run(MainApplication.class, args);     AccountService accService = ctx.getBean(AccountService.class);     accService.loadDictionary();   } What's the advantage? In integration tests with @SpringBootTest, the main method isn't run. Consequently, the code inside doesn't execute. No workarounds around PostConstruct, everything is clean and beautiful. When you still need "warming up" in tests, add the "use main method" parameter: @SpringBootTest(useMainMethod = SpringBootTest.UseMainMethod.ALWAYS) And that's it. If the code should execute after startup but will interfere with tests, write it in main. A very useful trick

6
49
2,484
Clockの固定の仕方に迷って時間がかかってしまった。TestConfigurationをつけた設定ファイルでBeanを上書きするのか?と思ったけど、それはSpringBootTestの場合で、Mockitoを使った単体テストの場合はフィールドで定義して実インスタンスをMockとともにBeforeEachで渡すのが正解の模様。
2
145
SpringBoot's @ SpringBootTest annotation boots up the full Spring context for integration tests. You can control what gets loaded via classes or config files, making it easy to test real wiring without starting the whole app. Clip @kenyanJug JBE Ep.4 🎥youtube.com/watch?v=CXgnTwvV…
1
6
1,017
🚨 ¡Alerta de mal hábito Spring! ¿Tu test tarda una eternidad? Quizá es porque usas @SpringBootTest hasta para testear un if 😵‍💫 ➡️ No todo necesita levantar el contexto 🔥 Menos magia, más velocidad #Java #SpringBoot #DevTips #CleanCode
2
106
💡 Spring Boot tip: @SpringBootTest(webEnvironment = RANDOM_PORT) allows integration tests on controllers. ✅ Starts a real embedded server ✅ The server runs on a random port. ✅ You can test controllers via TestRestTemplate or WebTestClient. #SpringBoot #JavaDev
1
5
42
1,458
SpringBootTestで動かしてるテスト、どうもJDBCコネクションをリークしてるっぽいんだけど、どこでリークが起きてるのか……🤔 どうやって犯人捜しするのが良いのかねえ
2
6
28
4,598
Spring Boot Tip 💡🍃 RestTestClient is a new unified REST APIs testing tool you can use instead of `WebTestClient`, `TestRestTemplate` (removed), or `MockMVC`. 👇 #springboot4 #junit #restapi #springboottest
3
30
195
6,269
Most important Springboot annotations that are used the most and also asked the most during interviews: ⇒Core Spring Boot Annotations → @ SpringBootApplication: Combines @ Configuration, @ EnableAutoConfiguration, and @ ComponentScan Entry point for a Spring Boot app → @ EnableAutoConfiguration: Automatically configures Spring app based on dependencies → @ ComponentScan: Scans the package for components, configurations, and services → @ Configuration: Marks a class as a source of bean definitions → @ Bean: Declares a bean (an object managed by the Spring container) ⇒Dependency Injection & Bean Management → @ Autowired: Injects a bean automatically → @ Qualifier: Used with @ Autowired to avoid conflicts between multiple beans → @ Value: Injects values from properties files → @ Primary: Marks a bean as the default choice when multiple candidates exist ⇒Security → @ EnableWebSecurity: Enables Spring Security's web security support → @ PreAuthorize: Authorizes access before method execution based on a condition → @ Secured: Restricts access based on roles → @ WithMockUser: Used in tests to simulate an authenticated user ⇒Data Access & JPA → @ Entity: Marks a class as a JPA entity → @ Table, @ Column: Configure table and column mappings → @ Id: Marks the primary key field → @ GeneratedValue: Specifies how the ID is generated → @ Repository: Marks a class as a DAO component and enables exception translation → @ Transactional: Manages transaction boundaries ⇒Web & REST Annotations → @ RequestMapping: Maps HTTP requests to handler methods (all methods) → @ GetMapping, @ PostMapping, @ PutMapping, @ DeleteMapping: Shorthand for @ RequestMapping(method=) → @ RequestBody: Binds HTTP request body to a method parameter → @ ResponseBody: Extracts a value from the URI path → @ PathVariable: Extracts a value from the URI path → @ RequestParam: Extracts query parameter values → @ RequestHeader: Accesses header values in a request ⇒Component Stereotypes → @ Component: Generic stereotype for Spring-managed components → @ Service: Specialization of @ Component, used for service classes →@ Repository: Specialization of @ Component, used for data access objects Adds exception translation → @ Controller: Marks a class as a web controller Used in MVC → @ RestController: Shortcut for @ Controller @ ResponseBody Used for REST APIs ⇒Testing → @ SpringBootTest: Boots the full application context for integration testing → @ DataJpaTest: Configures in-memory database and Spring Data JPA → @ MockBean: Replaces a bean in the context with a mock → @ WebMvcTest: Tests MVC controllers without starting the full context ⇒Spring Boot DevTools → @ EnableConfigurationProperties: Enables support for @ ConfigurationProperties beans → @ ConfigurationProperties: Binds external config (eg, applicationyml) to a POJO → @ Profile: Specifies that a bean is only active for a given profile
6
25
184
7,614
17 Oct 2025
Replying to @SumitM_X
Great checklist! The distinction between @SpringBootTest and @WebMvcTest is spot on—saves so much time on targeted testing. Any tips on integrating WireMock for those external REST mocks?
3
191