Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.0.0 , DataSourceBuilder not found in autoconfigure jar

Tags:

We are upgrading our existing Spring Boot (1.5) application to 2.0.0.

We connect with multiple databases and use the org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder class.

I added the dependency:

compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '2.0.0.RELEASE'  

However, I am not able to compile the project: This class (DataSourceBuilder) does not exist in the 2.0.0 version jar.

In order to rule out gradle issues, I manually downloaded the jar and added it to the classpath. This class does not exist in the version.

Also extracted and searched the jar but this class is missing. Can anyone help me resolve it?

like image 803
Smitha Santhosh Avatar asked Apr 24 '18 22:04

Smitha Santhosh


People also ask

What is datasourcebuilder in Spring Boot?

Spring Boot DataSourceBuilder example The following is a simple Spring Boot console application. It retrieves data from the H2 in-memory database and displays it in the terminal. To configure the datasource, we use the DataSourceBuilder class.

What is auto-configuration in Spring Boot?

Auto-configuration classes can be bundled in external jars and still be picked-up by Spring Boot. Auto-configuration can be associated to a "starter" that provides the auto-configuration code as well as the typical libraries that you would use with it.

How do I create a datasourcebuilder in Java?

Create a new DataSourceBuilder instance derived from the specified data source. Set the driver class name that should be used when building the datasource. Find the DataSource type preferred for the given classloader. Set the password that should be used when building the datasource. Set the DataSource type that should be built.

Do I need assembly-plugin with Spring Boot?

With Spring Boot, it is no longer necessary to use the assembly-plugin. Do not forget to call the package goal. Here is the documentation example. This does not seem to work if the spring application is just another dependency within another standalone jar. I have added this configuration in my pom and the issue got resolved:


1 Answers

The class was moved to another package. Its FQN is now org.springframework.boot.jdbc.DataSourceBuilder: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/jdbc/DataSourceBuilder.html

like image 102
dunni Avatar answered Sep 23 '22 14:09

dunni