Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

I was able to solve this by downgrading Spring Boot: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.3.3.RELEASE</version> </dependency> Guess it’s just not compatible with 2.4.0 yet. Specifically I also had to ensure that I used 2.3.3.RELEASE and not anything more recent due to other issues I ran across.

Spring Security: Upgrading the deprecated WebSecurityConfigurerAdapter in Spring Boot 2.7.0

I have managed to update the methods. This is the WebSecurityConfig class, and the methods are modified in the following way: public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); } has become: @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } Explanation: In the old version you inject AuthenticationManagerBuilder, set userDetailsService, passwordEncoder and … Read more

Spring boot – configure EntityManager

With Spring Boot its not necessary to have any config file like persistence.xml. You can configure with annotations Just configure your DB config for JPA in the application.properties spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@DB… spring.datasource.username=username spring.datasource.password=pass spring.jpa.database-platform=org.hibernate.dialect…. spring.jpa.show-sql=true Then you can use CrudRepository provided by Spring where you have standard CRUD transaction methods. There you can also implement your … Read more

Gradle 5 JUnit BOM and Spring Boot Incorrect Versions

How do I disable JUnit coming from the Gradle Spring Dependency Management plugin? For starters, if you are using the dependency management plugin from Spring, you should not be importing the junit-bom since that results in duplicate (and potentially conflicting) management of those dependencies. Aside from that, whenever you use the dependency management plugin from … Read more

How to access in memory h2 database of one spring boot application from another spring boot application

You can setup H2 Server as Spring Bean. First edit pom.xml – delete <scope>runtime</scope> from h2 dependency: <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> Then add H2 server bean to SpringBootApplication or Configuration class: @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } /** * Start internal H2 server so we can query … Read more

How to log request and response bodies in Spring WebFlux

This is more or less similar to the situation in Spring MVC. In Spring MVC, you can use a AbstractRequestLoggingFilter filter and ContentCachingRequestWrapper and/or ContentCachingResponseWrapper. Many tradeoffs here: if you’d like to access servlet request attributes, you need to actually read and parse the request body logging the request body means buffering the request body, … Read more