Hibernate SessionFactory injection on Spring Boot project is not working - java

I'm trying to make an MVC app with Spring Boot & Hibernate.
The sessionFactory field on PetController is marked as #Autowired and declared as a Spring bean in spring-configuration.xml but when I run the project it gives the following error:
The Class-Path manifest attribute in C:\Users\Murat\.m2\repository\com\mchange\c3p0\0.9.5.4\c3p0-0.9.5.4.jar referenced one or more files that do not exist: file:/C:/Users/Murat/.m2/repository/com/mchange/c3p0/0.9.5.4/mchange-commons-java-0.2.15.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2019-10-05 19:50:35.723 INFO 7260 --- [ restartedMain] website.murat.Application : Starting Application on DESKTOP-U59JGI0 with PID 7260 (C:\Users\Murat\IdeaProjects\vet-tracking-app\target\classes started by Murat in C:\Users\Murat\IdeaProjects\vet-tracking-app)
2019-10-05 19:50:35.727 INFO 7260 --- [ restartedMain] website.murat.Application : No active profile set, falling back to default profiles: default
2019-10-05 19:50:35.788 INFO 7260 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-10-05 19:50:35.788 INFO 7260 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-10-05 19:50:36.480 INFO 7260 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-10-05 19:50:36.502 INFO 7260 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13ms. Found 0 repository interfaces.
2019-10-05 19:50:36.818 INFO 7260 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d39eb974] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-05 19:50:37.143 INFO 7260 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-10-05 19:50:37.168 INFO 7260 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-10-05 19:50:37.168 INFO 7260 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-10-05 19:50:37.274 INFO 7260 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-10-05 19:50:37.274 INFO 7260 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1486 ms
2019-10-05 19:50:37.327 WARN 7260 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'petController': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.hibernate.SessionFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-10-05 19:50:37.329 INFO 7260 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-10-05 19:50:37.345 INFO 7260 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-05 19:50:37.522 ERROR 7260 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field sessionFactory in website.murat.controller.PetController required a bean of type 'org.hibernate.SessionFactory' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.hibernate.SessionFactory' in your configuration.
Process finished with exit code 0
PetController.java
package website.murat.controller;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import website.murat.model.Owner;
import website.murat.model.Pet;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
#Controller
#RequestMapping("/pet")
public class PetController {
#Autowired
private SessionFactory sessionFactory;
#GetMapping("/list")
public String showPetListPage(Model model) {
// creating some objects and binding to model in here.
return "pet-list";
}
#GetMapping("/add-new")
public String showAddNewPage(Model model) {
Pet pet = new Pet();
model.addAttribute("pet", pet);
return "add-new";
}
#PostMapping("/create-new")
public String addNew(#ModelAttribute("pet") #Valid Pet pet, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "add-new";
} else {
Session session = sessionFactory.getCurrentSession();
session.save(pet);
session.getTransaction().commit();
}
return "redirect:list";
}
}
spring-configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="mysqlDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.cj.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/spring_boot_example" />
<property name="user" value="vet_tracking_app_user" />
<property name="password" value="v?t!a.p-p_p+w" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="30000" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="mysqlDataSource" />
<property name="packagesToScan" value="website.murat" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
</beans>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>website.murat</groupId>
<artifactId>vet-tracking-app</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application.java (start point)
package website.murat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
After adding #ImportResource("classpath:spring-configuration.xml") annotation, logs are like below:
The Class-Path manifest attribute in C:\Users\Murat\.m2\repository\com\mchange\c3p0\0.9.5.4\c3p0-0.9.5.4.jar referenced one or more files that do not exist: file:/C:/Users/Murat/.m2/repository/com/mchange/c3p0/0.9.5.4/mchange-commons-java-0.2.15.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2019-10-05 21:20:41.993 INFO 20488 --- [ restartedMain] website.murat.Application : Starting Application on DESKTOP-U59JGI0 with PID 20488 (C:\Users\Murat\IdeaProjects\vet-tracking-app\target\classes started by Murat in C:\Users\Murat\IdeaProjects\vet-tracking-app)
2019-10-05 21:20:41.997 INFO 20488 --- [ restartedMain] website.murat.Application : No active profile set, falling back to default profiles: default
2019-10-05 21:20:42.044 INFO 20488 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-10-05 21:20:42.044 INFO 20488 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-10-05 21:20:42.927 INFO 20488 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-10-05 21:20:42.954 INFO 20488 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15ms. Found 0 repository interfaces.
2019-10-05 21:20:43.280 INFO 20488 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$21390086] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-05 21:20:43.629 INFO 20488 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-10-05 21:20:43.652 INFO 20488 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-10-05 21:20:43.653 INFO 20488 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-10-05 21:20:43.745 INFO 20488 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-10-05 21:20:43.745 INFO 20488 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1701 ms
2019-10-05 21:20:43.797 WARN 20488 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'petController': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-configuration.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2]
2019-10-05 21:20:43.799 INFO 20488 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-10-05 21:20:43.815 INFO 20488 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-05 21:20:43.826 ERROR 20488 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'petController': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-configuration.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at website.murat.Application.main(Application.java:11) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.6.RELEASE.jar:2.1.6.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-configuration.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:570) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 24 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:692) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:422) ~[spring-orm-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:406) ~[spring-orm-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:333) ~[spring-orm-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1077) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:567) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 33 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Lorg/hibernate/boot/model/naming/ImplicitNamingStrategy;
at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_201]
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_201]
at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_201]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 39 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.boot.model.naming.ImplicitNamingStrategy
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_201]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_201]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_201]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_201]
... 43 common frames omitted
Process finished with exit code 0

Spring can't find your beans. I guess your configuration file is just ignored by Spring.
From Spring Boot Docs :
Spring Boot favors Java-based configuration. Although it is possible to use SpringApplication with XML sources, we generally recommend that your primary source be a single #Configuration class.
...
If you absolutely must use XML based configuration. You can then use an #ImportResource annotation to load XML configuration files.
So you could try to do something like this:
#SpringBootApplication
#ImportResource("classpath:spring-configuration.xml")
public class Application
See official docs here
In addition to this, replace
this:
<property name="packagesToScan" value="website.murat" />
to:
<property name="packagesToScan" value="website.murat.model" />

Related

spring boot: getting this error - Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/study?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.16'
compile("org.springframework.boot:spring-boot-starter-jdbc")
compile('org.projectlombok:lombok')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
so, basically, I am trying to starting the setup for spring boot with Intellij using gradle.
and my db is mysql.
Thing is I searched every pieces of information regarding the error I am getting. But they are not helpful. I put all information needed for spring datasource in application.properties. and the location of it is correct which is under src/main/resources.
I don't know why it keeps getting this error below.
"C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.2\lib\idea_rt.jar=63471:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_201\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\el-api.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\jsp-api.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\ojdbc6.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\servlet-api.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\rt.jar;C:\sboot\build\classes\java\main;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.1.8.RELEASE\69a67eefdc71a6dbddc752fca94b39a49e06c435\spring-boot-starter-data-jpa-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.1.8.RELEASE\c728aa5023666554b74b57ee5edf0e47ba0af82b\spring-boot-starter-jdbc-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.18.8\448003bc1b234aac04b58e27d7755c12c3ec4236\lombok-1.18.8.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.1.8.RELEASE\36c0b75eaf07a68ac6e8a75c97a2bffa766ac147\spring-boot-starter-web-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.1.8.RELEASE\4978a5e339411af2934bdbb44640687748f4588b\spring-boot-starter-aop-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.1.8.RELEASE\910f1e7ee86175e16c1075cd714a1053453ece7d\spring-boot-starter-json-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\mysql\mysql-connector-java\5.1.37\2c378637f6faff77541244e8257b446f04324bd8\mysql-connector-java-5.1.37.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.1.8.RELEASE\18f402a493e49571624ff03b584032d499c66177\spring-boot-starter-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\3.2.0\6c66db1c636ee90beb4c65fe34abd8ba9396bca6\HikariCP-3.2.0.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.1.10.RELEASE\12639406aa28c3a5195a1a4c9077fe562f54bc31\spring-data-jpa-2.1.10.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.1.9.RELEASE\220169d217f7114706141fc0afba425a5b368dce\spring-orm-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.1.9.RELEASE\3fd70356ba8d7c00c4081c1a207766352624414e\spring-jdbc-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.3\e006adf5cf3cca2181d16bd640ecb80148ec0fce\javax.transaction-api-1.3.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.xml.bind\jaxb-api\2.3.1\8531ad5ac454cc2deb9d4d32c40c4d7451939b5d\jaxb-api-2.3.1.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.3.11.Final\8ca0850acb59ffda12729cb6d9a0c6bb3ba61b68\hibernate-core-5.3.11.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.1.9.RELEASE\a8aec853c345ed54a99627cee9f755ce7dbb734\spring-aspects-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.1.8.RELEASE\c36ad84fd6b814fd0ffbc6e0a594ca4a44b70318\spring-boot-starter-tomcat-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.17.Final\af73055fc4a103ab347c56e7da5a143d68a0170\hibernate-validator-6.0.17.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.1.9.RELEASE\b9d4a2140488f0e6f9aa231e7938ae18da77b637\spring-webmvc-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.1.9.RELEASE\9fe4390420fdd0b63dc4ed90d9027dafa9f74f80\spring-web-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.1.8.RELEASE\f243a54d052621fdc0ab5b2352d42cab1c05e2\spring-boot-autoconfigure-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.1.8.RELEASE\d37969b66e4a6d274f4100c22242ae15a260d529\spring-boot-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.1.8.RELEASE\ccd951d24bb3031e2ffab287fc66cf8efcb08436\spring-boot-starter-logging-2.1.8.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.1.9.RELEASE\a9125e2c8eeb193030f3972c6293616943c55ef2\spring-tx-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.1.9.RELEASE\c37f8fe15a5ae4ea1f351bd46167fd492a84eefa\spring-context-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.1.9.RELEASE\bc2312ffad02251b9d472e4a7c0e472a58f50fbf\spring-aop-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.1.10.RELEASE\c73a76070181b59b19df6893e1ca729263a69b47\spring-data-commons-2.1.10.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.1.9.RELEASE\5a03b3983108d73978aec2fa3e681aedad6782c\spring-beans-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.1.9.RELEASE\db3a2468c1b7d697ec3b3ec6e5652dc282994fe3\spring-expression-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.1.9.RELEASE\dc3815439579b4fa0c19970e6b8e5d774af8d988\spring-core-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.11.2\6d37bf7b046c0ce2669f26b99365a2cfa45c4c18\log4j-to-slf4j-2.11.2.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.28\c6f06c420ad62d3824b38a06dfdce9fb55ba81ef\jul-to-slf4j-1.7.28.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.28\2cd9b264f76e3d087ee21bfc99305928e1bdb443\slf4j-api-1.7.28.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.23\ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68\snakeyaml-1.23.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.4\9205229878f3d62fbd3a32a0fb6be2d6ad8589a9\aspectjweaver-1.9.4.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.activation\javax.activation-api\1.2.0\85262acf3ca9816f9537ca47d5adeabaead7cb16\javax.activation-api-1.2.0.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.4.Final\965a18fdf939ee75e41f7918532d37b3a8350535\hibernate-commons-annotations-5.0.4.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.3.Final\d3cfa8d3075fd52884fc82ded5c52b1407f18e6e\jboss-logging-3.3.3.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.persistence\javax.persistence-api\2.2\25665ac8c0b62f50e6488173233239120fc52c96\javax.persistence-api-2.2.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.23.2-GA\c5afe660a95e87ceb518e4f5cf02f5c56b547683\javassist-3.23.2-GA.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.9.16\e7d63009be7b87ff1f15b72e5b8c59c897a8d8bd\byte-buddy-1.9.16.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.5.Final\7060f67764565b9ee9d467e3ed0cb8a9c601b23a\jandex-2.0.5.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.4.0\291658ac2ce2476256c7115943652c0accb5c857\classmate-1.4.0.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.dom4j\dom4j\2.1.1\3dce5dbb3571aa820c677fadd8349bfa8f00c199\dom4j-2.1.1.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.9\4b04126963103216c9c43b0f34bbc36315654204\jackson-datatype-jdk8-2.9.9.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.9\a33df137557793b0404a486888dbe049f7abeeeb\jackson-datatype-jsr310-2.9.9.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.9\a92facb55a2538e7b2fe14294570a18b823ad431\jackson-module-parameter-names-2.9.9.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.9.3\68ddd453458765757fd3ffca9437f9a42d91003e\jackson-databind-2.9.9.3.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.24\2114edf511f94cb22159ec1bbcba37bcbdf9a9bd\tomcat-embed-websocket-9.0.24.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.24\ddf2ecf6976876e2569d507f033c613f6fa18f14\tomcat-embed-core-9.0.24.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.24\247854025c365cce5513cfd7bdcffc2fc2d74dd1\tomcat-embed-el-9.0.24.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.1.9.RELEASE\7c372790c999777d20f364960cf557dd74f890cf\spring-jcl-5.1.9.RELEASE.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.9\bfff5af9fb8347d26bbb7959cb9b4fe9a2b0ca5e\jackson-core-2.9.9.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\유광민\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.11.2\f5e9a2ffca496057d6891a3de65128efc636e26e\log4j-api-2.11.2.jar" com.example.study.StudyApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.8.RELEASE)
2019-09-13 20:27:40.398 INFO 29888 --- [ main] com.example.study.StudyApplication : Starting StudyApplication on KwangStark with PID 29888 (C:\sboot\build\classes\java\main started by 유광민 in C:\sboot)
2019-09-13 20:27:40.435 INFO 29888 --- [ main] com.example.study.StudyApplication : No active profile set, falling back to default profiles: default
2019-09-13 20:27:43.676 INFO 29888 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-13 20:27:43.775 INFO 29888 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 66ms. Found 0 repository interfaces.
2019-09-13 20:27:44.840 INFO 29888 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$64ec8457] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-13 20:27:46.238 INFO 29888 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-09-13 20:27:46.396 INFO 29888 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-13 20:27:46.397 INFO 29888 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-13 20:27:47.216 INFO 29888 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-13 20:27:47.216 INFO 29888 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6525 ms
2019-09-13 20:27:47.421 WARN 29888 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2019-09-13 20:27:47.428 INFO 29888 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-09-13 20:27:47.442 ERROR 29888 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Failed to destroy the filter named [Tomcat WebSocket (JSR356) Filter] of type [org.apache.tomcat.websocket.server.WsFilter]
java.lang.AbstractMethodError: null
at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:301) ~[tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4565) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5388) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) [tomcat-embed-core-9.0.24.jar:9.0.24]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.24.jar:9.0.24]
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_201]
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) [tomcat-embed-core-9.0.24.jar:9.0.24]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.24.jar:9.0.24]
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_201]
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:994) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:469) [tomcat-embed-core-9.0.24.jar:9.0.24]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:254) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:309) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.stopAndReleaseWebServer(ServletWebServerApplicationContext.java:306) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at com.example.study.StudyApplication.main(StudyApplication.java:14) [main/:na]
2019-09-13 20:27:47.533 WARN 29888 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2019-09-13 20:27:47.561 INFO 29888 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-13 20:27:47.569 ERROR 29888 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
Try to apply the following properties to your properties file:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect

Flyway: Cannot find migrations location in: [classpath:db/migration]

I created an new project with springboot2.2.0.M2 / Flyway 5.2.4 / Java8.
After try to start my project i got :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-22 13:36:54.574 INFO 17268 --- [ restartedMain] com.example.demo214.Demo214Application : Starting Demo214Application on xx-MacBook-Pro.local with PID 17268
2019-04-22 13:36:54.577 INFO 17268 --- [ restartedMain] com.example.demo214.Demo214Application : The following profiles are active: dev
2019-04-22 13:36:54.665 INFO 17268 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-04-22 13:36:54.665 INFO 17268 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-04-22 13:36:55.731 WARN 17268 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example.demo214]' package. Please check your configuration.
2019-04-22 13:36:55.939 INFO 17268 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-04-22 13:36:55.943 INFO 17268 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-22 13:36:55.983 INFO 17268 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 9ms. Found 0 repository interfaces.
2019-04-22 13:36:56.412 INFO 17268 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$631e07b5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-22 13:36:56.875 INFO 17268 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-04-22 13:36:56.901 INFO 17268 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-22 13:36:56.902 INFO 17268 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-22 13:36:57.103 INFO 17268 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-22 13:36:57.103 INFO 17268 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2438 ms
2019-04-22 13:36:57.257 INFO 17268 --- [ restartedMain] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2019-04-22 13:36:57.413 INFO 17268 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
2019-04-22 13:36:58.008 INFO 17268 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.1.0
Mon Apr 22 13:36:58 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2019-04-22 13:36:59.143 WARN 17268 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
2019-04-22 13:36:59.144 INFO 17268 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2019-04-22 13:36:59.170 INFO 17268 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2019-04-22 13:36:59.172 INFO 17268 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-04-22 13:36:59.184 INFO 17268 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-04-22 13:36:59.197 ERROR 17268 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at com.example.demo214.Demo214Application.main(Demo214Application.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.4.RELEASE.jar:2.1.4.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
... 26 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:194) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:153) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$e31bd555.CGLIB$flyway$0(<generated>) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$e31bd555$$FastClassBySpringCGLIB$$169da02e.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$e31bd555.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
... 27 common frames omitted
Process finished with exit code 1
I have a init sql under db/migration with name: V1.0.0__init.sql (just one line in it: use mydb;)
my flyway configuration in yml (ignore other datasource):
spring:
flyway:
baseline-on-migrate: true
locations: classpath:db/migration
I tried to debug it, found the FlywayAutoConfiguratioin.hasAtLeastOneLocation() always return false, it means not found the location (but the location looks like right in debugger), see the following screenshot:
appreciate any kind help :)
Make sure that you have not accidentally created a folder with the name db.migration, as opposed to the folders db/migration.
Intellij will show both as db.migration in the project files view, when you have the option "Compact Middle Packages" enabled.
Try to use in Spring Boot application.properties:
spring.flyway.check-location = false
It switches off Flyway migration scripts presents check.
Also see a set of default Flyway variables for Spring Boot
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
Mostly it happen because of copy paste. Make sure that you copy the script after creating folder structure like below
resources/
db/
migration/
_init.sql
IntelliJ shows both db.migration and db/migration to same as db.migration.
You can actual structure by clicking on top right gear sign and tick of flatten package. Hope this helps.
I got the same problem and for me helped creating new empty file in migration folder :
for example - init.sql
I already created db.migration folders exactly but still got this error, however I added this and it seemed like it worked
spring.flyway.check-location = false
For me the name of the scheme V1_1_schema.sql was wrong.
Changing it to V1_1__schema.sql solved the location issue.
Seems like Flyway requires double underscore __ in name prefix.
I solved this problem like this: first we create a "db folder" in "resources", then we create any file in the "db folder", then we create a "migration" subdirectory and already in it we create our migration file

Apache Ignite Hibernate L2 Cache with Spring Boot

I'm trying to develop a Spring Boot application with Iginte Hibernate L2 Cache.
Before I start my Spring Boot application, I run my server node. When I'm trying to run the Spring Boot Application I got the following error:
Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2018-11-28 18:14:50.291 INFO 20868 --- [ main] c.o.apache.ignite.learn.Application : Starting Application on DESKTOP-UNSVMQG with PID 20868 (C:\Users\patri\HibernateL2Cache\target\classes started by patri in C:\Users\patri\HibernateL2Cache)
2018-11-28 18:14:50.293 INFO 20868 --- [ main] c.o.apache.ignite.learn.Application : No active profile set, falling back to default profiles: default
2018-11-28 18:14:50.324 INFO 20868 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#50a638b5: startup date [Wed Nov 28 18:14:50 CET 2018]; root of context hierarchy
2018-11-28 18:14:51.353 INFO 20868 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-11-28 18:14:51.365 INFO 20868 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2018-11-28 18:14:51.366 INFO 20868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2018-11-28 18:14:51.463 INFO 20868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-11-28 18:14:51.464 INFO 20868 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1142 ms
2018-11-28 18:14:51.565 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-11-28 18:14:51.568 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-28 18:14:51.569 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-28 18:14:51.569 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-11-28 18:14:51.570 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-28 18:14:52.065 INFO 20868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-11-28 18:14:52.074 INFO 20868 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-11-28 18:14:52.123 INFO 20868 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2018-11-28 18:14:52.124 INFO 20868 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-11-28 18:14:52.125 INFO 20868 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2018-11-28 18:14:52.159 INFO 20868 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-11-28 18:14:52.248 INFO 20868 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-11-28 18:14:52.460 WARN 20868 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2018-11-28 18:14:52.536 INFO 20868 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-11-28 18:14:52.543 ERROR 20868 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.ontius.apache.ignite.learn.Application.main(Application.java:13) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:68) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:244) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
... 22 common frames omitted
Caused by: org.apache.ignite.IgniteIllegalStateException: Ignite instance with provided name doesn't exist. Did you call Ignition.start(..) to start an Ignite instance? [name=HibernateL2CacheGrid]
at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1383) ~[ignite-core-2.6.0.jar:2.6.0]
at org.apache.ignite.Ignition.ignite(Ignition.java:535) ~[ignite-core-2.6.0.jar:2.6.0]
at org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.start(HibernateAccessStrategyFactory.java:112) ~[ignite-hibernate-core-2.6.0.jar:2.6.0]
at org.apache.ignite.cache.hibernate.HibernateRegionFactory.start(HibernateRegionFactory.java:92) ~[ignite-hibernate_5.1-2.6.0.jar:2.6.0]
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:49) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:49) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
... 28 common frames omitted
Process finished with exit code 1
In order to get a better understanding of my code, I list the relvant code snippets below.
CacheConfigurationFactory
public class CacheConfigurationFactory {
public static List<CacheConfiguration> createCacheList() {
List<CacheConfiguration> cacheList = new ArrayList<CacheConfiguration>();
cacheList.add(createTransactionalCache("com.ontius.apache.ignite.learn.model.Person"));
cacheList.add(createAtomicCache("org.hibernate.cache.spi.UpdateTimestampsCache"));
cacheList.add(createAtomicCache("org.hibernate.cache.internal.StandardQueryCache"));
return cacheList;
}
private static CacheConfiguration createAtomicCache(String cacheName) {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheConfiguration.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfiguration.setName(cacheName);
return cacheConfiguration;
}
private static CacheConfiguration createTransactionalCache(String cacheName) {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheConfiguration.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfiguration.setName(cacheName);
return cacheConfiguration;
}
}
ServerConfigurationFactory
public class ServerConfigurationFactory {
public static IgniteConfiguration createConfiguration() {
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setClientMode(false);
igniteConfiguration.setIgniteInstanceName("HibernateL2CacheGrid");
igniteConfiguration.setPeerClassLoadingEnabled(true);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500:47509"));
discoverySpi.setIpFinder(ipFinder);
igniteConfiguration.setDiscoverySpi(discoverySpi);
List<CacheConfiguration> cacheList = CacheConfigurationFactory.createCacheList();
igniteConfiguration.setCacheConfiguration(cacheList.toArray(new CacheConfiguration[cacheList.size()]));
return igniteConfiguration;
}
}
ClientConfigurationFactory
public class ClientConfigurationFactory {
public static IgniteConfiguration createConfiguration() {
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setClientMode(true);
igniteConfiguration.setIgniteInstanceName("HibernateL2CacheGrid");
igniteConfiguration.setPeerClassLoadingEnabled(true);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500:47509"));
discoverySpi.setIpFinder(ipFinder);
igniteConfiguration.setDiscoverySpi(discoverySpi);
List<CacheConfiguration> cacheList = CacheConfigurationFactory.createCacheList();
igniteConfiguration.setCacheConfiguration(cacheList.toArray(new CacheConfiguration[cacheList.size()]));
return igniteConfiguration;
}
}
SessionFactoryConfiguration
#EnableAutoConfiguration
public class SessionFactoryConfiguration {
#Bean
public HibernateJpaSessionFactoryBean sessionFactory(EntityManagerFactory entityManagerFactory) {
HibernateJpaSessionFactoryBean hibernateJpaSessionFactoryBean = new HibernateJpaSessionFactoryBean();
hibernateJpaSessionFactoryBean.setEntityManagerFactory(entityManagerFactory);
return hibernateJpaSessionFactoryBean;
}
}
ServerNodeStartup
public class ServerNodeStartup {
public static void main(String[] args) {
Ignition.start(ServerConfigurationFactory.createConfiguration());
}
}
Application
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Bean
public IgniteSpringBean igniteInstance() {
IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
igniteSpringBean.setConfiguration(ClientConfigurationFactory.createConfiguration());
return igniteSpringBean;
}
}
application.yml
spring:
application:
name: HibernateL2Cache
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/demo_app?useSSL=false
username: root
password: demo
jpa:
properties:
hibernate:
show_sql: true
generate_statistics: true
cache:
use_query_cache: true
use_second_level_cache: true
region:
factory_class: org.apache.ignite.cache.hibernate.HibernateRegionFactory
org:
apache:
ignite:
hibernate:
ignite_instance_name: HibernateL2CacheGrid
default_access_type: READ_WRITE
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ontius.apache.ignite.learn</groupId>
<artifactId>hibernate-l2-cache</artifactId>
<version>1.0-SNAPSHOT</version>
<name>HibernateL2Cache</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ignite.version>2.6.0</ignite.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Apache Ignite -->
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-hibernate_5.1</artifactId>
<version>${ignite.version}</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I think I have to start ignite in the Spring Boot Application before the entityManagerFactory is initialized. But I don't know how I can achieve this.
First, you have a typo in your addresses: 127.0.0.1:47500:47509 should be 127.0.0.1:47500..47509.
Second, you have two options to link Hibernate L2 Cache to Ignite - start the Ignite node manually in the same JVM prior to Hibernate initialization or make Hibernate start it automatically.
Since you're using Spring Boot, and Ignite always starts last in the Spring contexts, it would probably be easier to go with the second approach.
To enable automatic Ignite startup you need to set org.apache.ignite.hibernate.grid_config property to a path of an Ignite XML configuration. Unfortunately, it seems that you can't use Java-based configuration here, only XML. You can convert your client configuration to an XML, put it into a resource under META-INF, say META-INF/ignite-client.xml, and then reference it (now without META-INF) - org.apache.ignite.hibernate.grid_config: ignite-client.xml. You should also remove the ignite_instance_name property (because it is overridden by grid_config) and the Ignite bean in the client application (because it is now started by Hibernate).
I know this is an old post. But let me put my view on this issue here.
The reason for this issue is Spring Boot is staring before Ignite. To fix it, we need to make sure Ignite is starting before Spring Boot.
If you change your "Application.java" as below, it should work.
#SpringBootApplication
public class Application {
public static void main(String[] args) {
IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
igniteSpringBean.setConfiguration(ClientConfigurationFactory.createConfiguration());
SpringApplication.run(Application.class, args);
}
}

Spring boot Jaxb Exception [duplicate]

This question already has answers here:
How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
(43 answers)
Closed 5 years ago.
I am biulding a spring boot application. but not getting the desired output. Can anyone help for this basic application.
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource
[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
Topic.java
package com.example.demo.topics;
import javax.persistence.Entity;
import javax.persistence.Id;
#Entity
public class Topic {
#Id
String topicId;
String topicName;
String topicDescription;
public Topic() {}
public Topic(String topicId, String topicName, String topicDescription) {
super();
this.topicId = topicId;
this.topicName = topicName;
this.topicDescription = topicDescription;
}
public String getTopicId() {
return topicId;
}
public void setTopicId(String topicId) {
this.topicId = topicId;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public String getTopicDescription() {
return topicDescription;
}
public void setTopicDescription(String topicDescription) {
this.topicDescription = topicDescription;
}
}
Controller class
package com.example.demo.topics;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class TopicController {
#Autowired
TopicService topicService;
#RequestMapping("/")
private String getWelcome() {
return "Hello";
}
#RequestMapping("/topics")
private List<Topic> getTopics() {
return topicService.getTopics();
}
#RequestMapping("/topics/{id}")
private Topic getTopicById(String id) {
return topicService.getTopicbyId(id);
}
#RequestMapping(method=RequestMethod.POST, value="/topics/{id}")
private void putTopic(Topic topic) {
topicService.putTopic(topic);
}
}
Repository Class
package com.example.demo.topics;
import org.springframework.data.repository.CrudRepository;
public interface TopicRepository extends CrudRepository<Topic,String>{
}
Service class
package com.example.demo.topics;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#Service
public class TopicService {
#Autowired
private TopicRepository topicRepository;
public List<Topic> getTopics() {
List<Topic> topics= new ArrayList<Topic>();
topicRepository.findAll().forEach(topics::add);
return topics;
}
public Topic getTopicbyId(String id) {
return topicRepository.findOne(id);
}
public void putTopic(Topic topic) {
topicRepository.save(topic);
}
}
pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.example</groupId>
<artifactId>springboottopics</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboottopics</name>
<description>First Java Brains project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.9</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
console:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
2017-12-29 20:29:50.365 INFO 2941 --- [ main] c.e.demo.SpringboottopicsApplication : Starting SpringboottopicsApplication on Abhays-MacBook-Air.local with PID 2941 (/Users/abhaysingh/Documents/workspace-sts-3.9.2.RELEASE/springboottopics/target/classes started by abhaysingh in /Users/abhaysingh/Documents/workspace-sts-3.9.2.RELEASE/springboottopics)
2017-12-29 20:29:50.373 INFO 2941 --- [ main] c.e.demo.SpringboottopicsApplication : No active profile set, falling back to default profiles: default
2017-12-29 20:29:50.481 INFO 2941 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#17503f6b: startup date [Fri Dec 29 20:29:50 IST 2017]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/abhaysingh/.m2/repository/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2017-12-29 20:29:53.356 INFO 2941 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-12-29 20:29:53.402 INFO 2941 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-12-29 20:29:53.405 INFO 2941 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23
2017-12-29 20:29:53.690 INFO 2941 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-12-29 20:29:53.691 INFO 2941 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3231 ms
2017-12-29 20:29:54.249 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-29 20:29:54.275 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-29 20:29:54.276 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-12-29 20:29:54.277 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-12-29 20:29:54.278 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-12-29 20:29:57.297 INFO 2941 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-12-29 20:29:57.352 INFO 2941 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-12-29 20:29:57.627 INFO 2941 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-12-29 20:29:57.634 INFO 2941 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-12-29 20:29:57.640 INFO 2941 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-12-29 20:29:57.686 WARN 2941 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
2017-12-29 20:29:57.696 INFO 2941 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-12-29 20:29:57.760 INFO 2941 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-12-29 20:29:57.807 ERROR 2941 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at com.example.demo.SpringboottopicsApplication.main(SpringboottopicsApplication.java:12) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na]
... 27 common frames omitted
Did you registered the spring.datasource , hibernate dialects in application.properties? Just for doubt
Like
spring.datasource.url=jdbc:mysql://localhost:3306/database
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = none
You are missing the hibernate-core dependency
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.11.Final</version>
</dependency>

Spring Boot JPA Error: Why am I not able to use Command Line Runner to persist an object to the database?

I am trying to simply persist an object into the database and then retrieve it to check that it has worked. I have had the same error for the past few days and I'm not sure what the issue is. I noticed that when I take the #Bean annotation out from in front of the demo function in Application.java, it doesn't error, but it also doesn't successfully persist to the database.
I attached all relevant files below.
This is my Data Object:
package dataObjects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="LoadMethod")
public class LoadMethodDO {
private String mediaId;
private String activeInd;
private String loadMethod;
private String formatMapCd;
private String detailTransactionReportInd;
private String accountManaged;
public LoadMethodDO(){}
public LoadMethodDO(String mediaId, String loadMethod){
this.mediaId = mediaId;
this.loadMethod = loadMethod;
}
#Id
#Column(name="Media_ID", length = 7)
public String getMediaId() {
return mediaId;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
#Column(name="ActInd")
public String getActiveInd() {
return activeInd;
}
public void setActiveInd(String activeInd) {
this.activeInd = activeInd;
}
#Column(name="LoadMthdCd")
public String getLoadMethod() {
return loadMethod;
}
public void setLoadMethod(String loadMethod) {
this.loadMethod = loadMethod;
}
#Column(name="FormatMapCd")
public String getFormatMapCd() {
return formatMapCd;
}
public void setFormatMapCd(String formatter) {
this.formatMapCd = formatter;
}
#Column(name="DtlTransRcdInd")
public String getDetailTransactionReportInd() {
return detailTransactionReportInd;
}
public void setDetailTransactionReportInd(String detailTransactionReportInd) {
this.detailTransactionReportInd = detailTransactionReportInd;
}
#Column(name="AcctMngdInd")
public String getAccountManaged() {
return accountManaged;
}
public void setAccountManaged(String accountManaged) {
this.accountManaged = accountManaged;
}
}
This is my repository file:
package repositories;
import org.springframework.data.repository.CrudRepository;
import dataObjects.LoadMethodDO;
public interface LoadMethodRepository extends CrudRepository<LoadMethodDO, String>{
}
This is my Application file that should persist the object:
package testApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import dataObjects.LoadMethodDO;
import repositories.LoadMethodRepository;
#SpringBootApplication
#EnableJpaRepositories
#EnableCaching
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
System.out.println("*****************");
SpringApplication.run(DBController.class, args);
}
#Bean
public CommandLineRunner demo(LoadMethodRepository repository) {
return (args) -> {
// save
repository.save(new LoadMethodDO("12345678", "1234567"));
// fetch
LoadMethodDO temp = repository.findOne("1234567");
System.out.println(temp.getMediaId());
};
}
}
This is my error code:
*****************
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.6.RELEASE)
2016-08-02 09:12:07.024 INFO 29732 --- [ main] testApplication.Application : Starting Application on LR90KLWJY with PID 29732 (C:\Users\vincni\git\consumer_load_method\bin started by vincni in C:\Users\vincni\git\consumer_load_method)
2016-08-02 09:12:07.040 INFO 29732 --- [ main] testApplication.Application : No active profile set, falling back to default profiles: default
2016-08-02 09:12:07.055 INFO 29732 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#543e710e: startup date [Tue Aug 02 09:12:07 PDT 2016]; root of context hierarchy
2016-08-02 09:12:07.102 WARN 29732 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DBController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: repositories.LoadMethodRepository testApplication.DBController.lmr; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [repositories.LoadMethodRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2016-08-02 09:12:07.118 ERROR 29732 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DBController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: repositories.LoadMethodRepository testApplication.DBController.lmr; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [repositories.LoadMethodRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
at testApplication.Application.main(Application.java:25) [bin/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: repositories.LoadMethodRepository testApplication.DBController.lmr; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [repositories.LoadMethodRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
... 16 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [repositories.LoadMethodRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
... 18 common frames omitted
2016-08-02 09:12:07.118 INFO 29732 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Users/vincni/git/consumer_load_method/bin/, file:/C:/apps/Ivy/cache/org.apache.camel/camel-ftp/jars/camel-ftp-2.16.1.jar, file:/C:/apps/Ivy/cache/org.apache.camel/camel-core/bundles/camel-core-2.16.1.jar, file:/C:/apps/Ivy/cache/com.sun.xml.bind/jaxb-core/jars/jaxb-core-2.2.11.jar, file:/C:/apps/Ivy/cache/com.sun.xml.bind/jaxb-impl/jars/jaxb-impl-2.2.11.jar, file:/C:/apps/Ivy/cache/com.jcraft/jsch/jars/jsch-0.1.53.jar, file:/C:/apps/Ivy/cache/commons-net/commons-net/jars/commons-net-3.3.jar, file:/C:/apps/Ivy/cache/com.zaxxer/HikariCP/jars/HikariCP-2.4.7.jar, file:/C:/apps/Ivy/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.21.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-starter-data-jpa/jars/spring-boot-starter-data-jpa-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-starter/jars/spring-boot-starter-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot/jars/spring-boot-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-core/jars/spring-core-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-context/jars/spring-context-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-aop/jars/spring-aop-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/aopalliance/aopalliance/jars/aopalliance-1.0.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-beans/jars/spring-beans-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-expression/jars/spring-expression-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-autoconfigure/jars/spring-boot-autoconfigure-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-starter-logging/jars/spring-boot-starter-logging-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.7.jar, file:/C:/apps/Ivy/cache/ch.qos.logback/logback-core/jars/logback-core-1.1.7.jar, file:/C:/apps/Ivy/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.21.jar, file:/C:/apps/Ivy/cache/org.slf4j/jul-to-slf4j/jars/jul-to-slf4j-1.7.21.jar, file:/C:/apps/Ivy/cache/org.slf4j/log4j-over-slf4j/jars/log4j-over-slf4j-1.7.21.jar, file:/C:/apps/Ivy/cache/org.yaml/snakeyaml/bundles/snakeyaml-1.16.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-starter-aop/jars/spring-boot-starter-aop-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.9.jar, file:/C:/apps/Ivy/cache/org.springframework.boot/spring-boot-starter-jdbc/jars/spring-boot-starter-jdbc-1.3.6.RELEASE.jar, file:/C:/apps/Ivy/cache/org.apache.tomcat/tomcat-jdbc/jars/tomcat-jdbc-8.0.36.jar, file:/C:/apps/Ivy/cache/org.apache.tomcat/tomcat-juli/jars/tomcat-juli-8.0.36.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-jdbc/jars/spring-jdbc-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-tx/jars/spring-tx-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.hibernate/hibernate-entitymanager/jars/hibernate-entitymanager-4.3.11.Final.jar, file:/C:/apps/Ivy/cache/org.jboss.logging/jboss-logging/jars/jboss-logging-3.3.0.Final.jar, file:/C:/apps/Ivy/cache/org.jboss.logging/jboss-logging-annotations/jars/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/apps/Ivy/cache/org.hibernate/hibernate-core/jars/hibernate-core-4.3.11.Final.jar, file:/C:/apps/Ivy/cache/dom4j/dom4j/jars/dom4j-1.6.1.jar, file:/C:/apps/Ivy/cache/xml-apis/xml-apis/jars/xml-apis-1.0.b2.jar, file:/C:/apps/Ivy/cache/org.hibernate.common/hibernate-commons-annotations/jars/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/apps/Ivy/cache/org.hibernate.javax.persistence/hibernate-jpa-2.1-api/jars/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/apps/Ivy/cache/org.javassist/javassist/bundles/javassist-3.18.1-GA.jar, file:/C:/apps/Ivy/cache/antlr/antlr/jars/antlr-2.7.7.jar, file:/C:/apps/Ivy/cache/org.jboss/jandex/jars/jandex-1.1.0.Final.jar, file:/C:/apps/Ivy/cache/javax.transaction/javax.transaction-api/jars/javax.transaction-api-1.2.jar, file:/C:/apps/Ivy/cache/org.springframework.data/spring-data-jpa/jars/spring-data-jpa-1.9.4.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework.data/spring-data-commons/jars/spring-data-commons-1.11.4.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-orm/jars/spring-orm-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.springframework/spring-aspects/jars/spring-aspects-4.2.7.RELEASE.jar, file:/C:/apps/Ivy/cache/org.apache.camel/camel-jpa/jars/camel-jpa-2.10.0.jar, file:/C:/apps/Ivy/cache/org.apache.camel/camel-spring/bundles/camel-spring-2.10.0.jar, file:/C:/apps/Ivy/cache/org.apache.poi/poi/jars/poi-3.10.1.jar, file:/C:/apps/Ivy/cache/commons-codec/commons-codec/jars/commons-codec-1.5.jar, file:/C:/apps/Ivy/cache/org.apache.poi/poi-ooxml/jars/poi-ooxml-3.10.1.jar, file:/C:/apps/Ivy/cache/org.apache.poi/poi-ooxml-schemas/jars/poi-ooxml-schemas-3.10.1.jar, file:/C:/apps/Ivy/cache/org.apache.xmlbeans/xmlbeans/jars/xmlbeans-2.6.0.jar, file:/C:/apps/Ivy/cache/stax/stax-api/jars/stax-api-1.0.1.jar, file:/C:/apps/Ivy/cache/com.microsoft.sqlserver/sqljdbc4/jars/sqljdbc4-4.0.jar, file:/C:/ExternalJARS/ojdbc7.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/eclipselink.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/jpa/javax.persistence_2.1.0.v201304241213.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/jpa/org.eclipse.persistence.jpa.modelgen_2.5.2.v20140319-9ad6abd.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/jpa/org.eclipse.persistence.jpars_2.5.2.v20140319-9ad6abd.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/com.sun.tools.xjc_2.2.0.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/com.sun.xml.bind_2.2.0.v201004141950.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/javax.activation_1.1.0.v201108011116.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/javax.mail_1.4.0.v201005080615.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/javax.xml.bind_2.2.0.v201105210648.jar, file:/C:/Users/vincni/workspace/workspace_lmt/libraries/EclipseLink%202.5.2/eclipselink/jlib/moxy/javax.xml.stream_1.0.1.v201004272200.jar]
Console message if I take #bean out from in front of the demo function. I thought it might be interesting to see, but I am almost 100% percent sure the bean should be there. It doesn't persist anything without it and every source I have seen online says to put the #bean annotation there:
*****************
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.6.RELEASE)
2016-08-02 09:41:56.284 INFO 34864 --- [ main] testApplication.Application : Starting Application on LR90KLWJY with PID 34864 (C:\Users\vincni\git\consumer_load_method\bin started by vincni in C:\Users\vincni\git\consumer_load_method)
2016-08-02 09:41:56.300 INFO 34864 --- [ main] testApplication.Application : No active profile set, falling back to default profiles: default
2016-08-02 09:41:56.347 INFO 34864 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#15bfd87: startup date [Tue Aug 02 09:41:56 PDT 2016]; root of context hierarchy
2016-08-02 09:41:58.537 INFO 34864 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-08-02 09:41:58.538 INFO 34864 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-08-02 09:41:58.638 INFO 34864 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}
2016-08-02 09:41:58.638 INFO 34864 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-08-02 09:41:58.638 INFO 34864 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-08-02 09:41:58.794 INFO 34864 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-08-02 09:41:58.855 WARN 34864 --- [ main] o.h.e.j.d.i.StandardDialectResolver : HHH000385: Unknown Microsoft SQL Server major version [12] using SQL Server 2000 dialect
2016-08-02 09:41:58.862 INFO 34864 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
2016-08-02 09:41:58.935 INFO 34864 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-08-02 09:41:59.013 INFO 34864 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2016-08-02 09:41:59.013 INFO 34864 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata
2016-08-02 09:41:59.013 INFO 34864 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema
2016-08-02 09:41:59.013 INFO 34864 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000232: Schema update complete
2016-08-02 09:41:59.248 INFO 34864 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-08-02 09:41:59.259 INFO 34864 --- [ main] testApplication.Application : Started Application in 3.326 seconds (JVM running for 3.833)
2016-08-02 09:41:59.261 INFO 34864 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#15bfd87: startup date [Tue Aug 02 09:41:56 PDT 2016]; root of context hierarchy
2016-08-02 09:41:59.263 INFO 34864 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2016-08-02 09:41:59.263 INFO 34864 --- [ Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
This is because your entity, repositories and applications are in different packages and you didn't mention spring boot to scan packages for entities and other configurations.
#SpringBootApplication
#EnableJpaRepositories(basePackages = { "repositories" })
#EntityScan(basePackages = { "dataObjects" })
public class Application
Note: By default it will scan the current and sub-directories of SpringBootApplication annotated class. If you keep all your entity and repositories (other components) in the sub packages of SpringBootApplication annotated class then you don't need to mention the packages names to scan.

Categories

Resources