Reputation:
I have a project and I just added MySQL support to it, along with JPA and others:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
...
I then configured the application.properties
file as follows:
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/spring
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
But then, this error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
I don't understand very well what's this and why it is happening. I thought Boot was supposed to take care of the main configuration? I even generated a new project with these dependencies as default but the same error persists.
Upvotes: 0
Views: 102
Reputation:
The reason behind this was the Java version. I had version 14, o I uninstalled it and installed the latest LTS version, 11
sudo apt purge openjdk-14*
updated the pom.xml
to use the same version, then I erased everything generated regarding of configuration and opened it again to generate them again, and everything worked.
Upvotes: 3
Reputation: 11
If you have any Service and Data layer. please annotate it with @Repository and @Service annotation
Please go through mkyong java basic tutorials.
Upvotes: 0
Reputation: 519
Add following properties and try again
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL57Dialect
Hope this solve your problem :)
Upvotes: 0