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?
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.
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.
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.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With