Error connecting to database Spring boot - spring

Helo I have been trying to connect to a database with Spring Boot for a while and I keep getting the error:
java.sql.SQLException: The url cannot be null
I am not sure what is it that I am doing wrong. The reason I am trying to get the configuration like this is because I want to use the encoded password for the database.
This is what my files look like:
DataConfig.java
#Configuration
public class DataConfig {
#Autowired
private Environment env;
#Configuration
#Profile(value = "dev")
public class DevPlaceHolderConfig {
#Bean
DataSource dataSource() {
return DataSourceBuilder
.create()
.username(env.getProperty("spring.datasource.username"))
.password(env.getProperty("spring.datasource.password"))
.url(env.getProperty("spring.datasource.url"))
.driverClassName(env.getProperty("spring.datasource.driver-class-name"))
.build();
}
}
#Configuration
#Profile(value = "prod")
public class ProdPlaceHolderConfig {
#Bean
DataSource dataSource() {
return DataSourceBuilder
.create()
.username(env.getProperty("spring.datasource.username"))
.password(env.getProperty("spring.datasource.password"))
.url(env.getProperty("spring.datasource.url"))
.driverClassName(env.getProperty("spring.datasource.driver-class-name"))
.build();
}
}
}
EncryptorConfig.java
#Configuration
public class EncryptorConfig {
#Bean
public EnvironmentStringPBEConfig environmentVariablesConfiguration() {
EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
config.setAlgorithm("PBEWithMD5AndDES");
config.setPasswordEnvName("APP_ENCRYPTION_PASSWORD");
return config;
}
#Bean
public PooledPBEStringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
encryptor.setConfig(environmentVariablesConfiguration());
return encryptor;
}
}
application.yml
spring:
profiles:
active: prod
output:
ansi:
enabled: always
---
spring:
profiles: dev
application:
name: App-Dev
datasource:
url: jdbc:mysql://localhost:3306/database?useSSL=false
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
server:
port: 8080
---
spring:
profiles: prod
application:
name: App-Prod
datasource:
url: jdbc:mysql://localhost:3306/database?useSSL=false
username: root
password: ENC(/98CfxmsjKBW5oZsLkLlmw==)
driver-class-name: com.mysql.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
server:
port: 3000
Here is the stack trace
2017-09-04 09:20:02.476 INFO 18128 --- [ main] com.vir.VirBackendApplication : The following profiles are active: prod
2017-09-04 09:20:02.536 INFO 18128 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1ebd319f: startup date [Mon Sep 04 09:20:02 EDT 2017]; root of context hierarchy
2017-09-04 09:20:03.479 INFO 18128 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.vir.config.DataConfig$ProdPlaceHolderConfig; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/vir/config/DataConfig$ProdPlaceHolderConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.vir.config.EncryptorConfig$ProdPlaceHolderConfig; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/vir/config/EncryptorConfig$ProdPlaceHolderConfig.class]]
2017-09-04 09:20:03.898 INFO 18128 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-09-04 09:20:04.112 INFO 18128 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$55ffc8cc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-09-04 09:20:04.421 INFO 18128 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 5000 (http)
2017-09-04 09:20:04.431 INFO 18128 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-09-04 09:20:04.432 INFO 18128 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-09-04 09:20:04.589 INFO 18128 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-09-04 09:20:04.589 INFO 18128 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2055 ms
2017-09-04 09:20:04.764 INFO 18128 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-09-04 09:20:04.769 INFO 18128 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-09-04 09:20:04.769 INFO 18128 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-09-04 09:20:04.769 INFO 18128 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-09-04 09:20:04.769 INFO 18128 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-09-04 09:20:04.817 INFO 18128 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-09-04 09:20:04.820 INFO 18128 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-09-04 09:20:04.821 INFO 18128 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-09-04 09:20:04.967 WARN 18128 --- [ main] o.a.tomcat.jdbc.pool.PooledConnection : Not loading a JDBC driver as driverClassName property is null.
2017-09-04 09:20:04.978 ERROR 18128 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
java.sql.SQLException: The url cannot be null
at java.sql.DriverManager.getConnection(Unknown Source) ~[na:1.8.0_144]
at java.sql.DriverManager.getConnection(Unknown Source) ~[na:1.8.0_144]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:308) ~[tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.16.jar:na]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:326) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:366) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:72) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:139) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:105) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$bf862cec.CGLIB$jpaVendorAdapter$9(<generated>) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$bf862cec$$FastClassBySpringCGLIB$$3d2e4b4f.invoke(<generated>) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$bf862cec.jpaVendorAdapter(<generated>) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_144]

Ok so it took me a while but this is how I solved my issues; which turned out to be a few.
Make sure you include a property placeholder in the configuration so then the actual property value can bind to.
Make sure to read about it here enter link description here
So now my application.yml file looks like bellow, and APP_ENCRYPTION_PASSWORD is an environment variable holding the encryption password.
spring:
profiles:
active: prod
output:
ansi:
enabled: detect
---
spring:
profiles: dev
application:
name: App-Dev
datasource:
url: jdbc:mysql://localhost:3306/database?useSSL=false
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
server:
port: 8080
---
spring:
profiles: prod
application:
name: App-Prod
datasource:
url: jdbc:mysql://localhost:3306/database?useSSL=false
username: root
password: ENC(/98CfxmsjKBW5oZsLkLlmw==)
driver-class-name: com.mysql.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
jasypt:
encryptor:
algorithm: PBEWithMD5AndDES
password: ${APP_ENCRYPTION_PASSWORD}
server:
port: 3000
Only one data source configuration bean needed. I have it set to change active profiles so the correct configuration is picked.
Also create private variables and bind them with a #Value() annotation. Also add the #EnableEncryptableProperties to the class.
DataConfig.java
#Configuration
#EnableEncryptableProperties
public class DataConfig {
#Value("${spring.datasource.username}")
private String userName;
#Value("${spring.datasource.password}")
private String password;
#Value("${spring.datasource.url}")
private String url;
#Value("${spring.datasource.driver-class-name}")
private String driverClassName;
#Bean
DataSource dataSource() {
return DataSourceBuilder
.create()
.username(userName)
.password(password)
.url(url)
.driverClassName(driverClassName)
.build();
}
}
And that's it it solved all my problems.

Related

Spring Cloud Config Server - Properties not being picked up

We are trying to add Spring Cloud Config Server to our project to externalize the configuration.
We have created a Config Server which connects to the Git repo and seems to be working correctly. However when we start a sample client it we get a message fetching config from server. Located environment but then a message to set a property which we have set in the corresponding yaml file in the git repo.
Config Server bootStrap.yml
spring:
application:
name: configuration-service
server:
port: 8888
Config Server application.yml
spring:
profiles:
active: dev
security:
user:
name: root
password: M5awantk
cloud:
config:
server:
git:
clone-on-start: true
uri: https://git.assembla.com/*********
username: ***********
password: ***********
Hitting http://localhost:8080/notification-service/default gives the following which is correct
{
name: "notification-service",
profiles: [
"default"
],
label: null,
version: "21ee5025b232b812e0e64387cd577eeda0351214",
state: null,
propertySources: [
{
name: "https://git.assembla.com/pins-configuration.git/notification-service.yml",
source: {
spring.main.allow-bean-definition-overriding: true,
spring.application.name: "notification-service",
spring.zipkin.baseUrl: "http://localhost:9411/",
spring.jpa.properties.hibernate.cache.use_second_level_cache: true,
spring.jpa.properties.hibernate.cache.use_query_cache: true,
server.port: 8091,
server.compression.enabled: true,
server.compression.min-response-size: 2048,
server.compression.mime-types: "application/json,application/xml,text/html,text/plain",
eureka.instance.hostname: "localhost",
eureka.instance.port: 8761,
eureka.instance.leaseRenewalIntervalInSeconds: 3,
eureka.instance.instanceId:
"${spring.application.name}:${spring.application.instance_id:${random.value}}",
eureka.client.registryFetchIntervalSeconds: 5,
eureka.client.instanceInfoReplicationIntervalSeconds: 5,
eureka.client.initialInstanceInfoReplicationIntervalSeconds: 5,
eureka.client.serviceUrl.defaultZone:
"http://${eureka.instance.hostname}:${eureka.instance.port}/eureka/"
}
}
]
}
Client (named notification-service)
Client bootstrap.yml
spring:
cloud:
config:
uri: http://localhost:8888
username: root
password: M5awantk
name: notification-service
application:
name: notifcation-service
On staring the notification-service it seems to find the config service and the notification-service.yml as expected but then we get an error
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Although we have the following in notification-service.yml and it shows when we hit http://localhost:8080/notification-service/default
spring.main.allow-bean-definition-overriding: true
Console output when starting notification-service
2020-03-24 18:26:03.046 INFO [notifcation-service,,,] 24238 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-03-24 18:26:04.847 INFO [notifcation-service,,,] 24238 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=notification-service, profiles=[default], label=null, version=21ee5025b232b812e0e64387cd577eeda0351214, state=null
2020-03-24 18:26:04.848 INFO [notifcation-service,,,] 24238 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: OriginTrackedCompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, OriginTrackedMapPropertySource {name='https://git.assembla.com/pins-configuration.git/notification-service.yml'}]}
2020-03-24 18:26:04.900 INFO [notifcation-service,,,] 24238 --- [ main] c.s.p.n.NotificationServiceApplication : The following profiles are active: dev
2020-03-24 18:26:06.237 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-24 18:26:06.464 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 217ms. Found 3 JPA repository interfaces.
2020-03-24 18:26:06.474 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-24 18:26:06.615 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 140ms. Found 21 JPA repository interfaces.
2020-03-24 18:26:06.616 WARN [notifcation-service,,,] 24238 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'jpaAuditingHandler' defined in null: Cannot register bean definition [Root bean: class [org.springframework.data.auditing.AuditingHandler]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'jpaAuditingHandler': There is already [Root bean: class [org.springframework.data.auditing.AuditingHandler]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2020-03-24 18:26:06.626 INFO [notifcation-service,,,] 24238 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-24 18:26:06.630 ERROR [notifcation-service,,,] 24238 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'jpaAuditingHandler' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Not sure what we might be doing wrong.
EDIT: I have managed to get a very simple application working with just one property set in the corresponding application.yml.
Wondering if it is something to do with properties not being available in time, although from the console output that would not appear to be the case.

Error running gradle bootrun

I am trying to do gradle bootRun using IntelliJ, but this error appears:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':bootRun'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe'' finished with non-zero exit value 1
In the Console I have this:
2017-06-21 10:13:54.177 INFO 12008 --- [ main] com.nice_system.nicemedia.ApplicationKt : Starting ApplicationKt on DESKTOP-GHI2UHL with PID 12008 (started by Darja Strahlberg in C:\Users\Darja Strahlberg
\code\versuch\nto_niceMediaServer)
2017-06-21 10:13:54.182 INFO 12008 --- [ main] com.nice_system.nicemedia.ApplicationKt : No active profile set, falling back to default profiles: default
2017-06-21 10:13:54.310 INFO 12008 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5be6e01c: start
up date [Wed Jun 21 10:13:54 CEST 2017]; root of context hierarchy
2017-06-21 10:13:56.234 INFO 12008 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'httpRequestHandlerAdapter' with a different definition: replacing [Root bean:
class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$Ena
bleWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurat
ion$EnableWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframew
ork.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/re
st/webmvc/config/RepositoryRestMvcConfiguration.class]]
2017-06-21 10:13:57.102 INFO 12008 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframe
work.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$dc898557] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-06-21 10:13:57.776 INFO 12008 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8081 (http)
2017-06-21 10:13:57.797 INFO 12008 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-06-21 10:13:57.800 INFO 12008 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-06-21 10:13:58.025 INFO 12008 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-06-21 10:13:58.025 INFO 12008 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3719 ms
2017-06-21 10:13:58.319 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally u
nnecessary.
2017-06-21 10:14:00.929 ERROR 12008 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
This is my build.gradle file:
plugins {
id "org.jetbrains.kotlin.jvm" version "1.1.2"
id "org.jetbrains.kotlin.plugin.noarg" version "1.1.2"
id "org.jetbrains.kotlin.plugin.jpa" version "1.1.2"
id "org.springframework.boot" version "1.5.3.RELEASE"}
jar {
baseName = 'nicemedia-api'
version = '0.1.0'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-data-rest"
testCompile "org.springframework.boot:spring-boot-starter-test"
runtime "mysql:mysql-connector-java:6.0.6"
runtime "com.h2database:h2"
}
repositories {
mavenCentral()
}

cannot find DiscoveryClient bean error in spring boot

2017-03-16 16:09:08.821 INFO 9104 --- [ main] com.hello.EurekaClientApplication : No active profile set, falling back to default profiles: default
2017-03-16 16:09:08.848 INFO 9104 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5dcd8c7a: startup date [Thu Mar 16 16:09:08 CDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#441772e
2017-03-16 16:09:09.873 INFO 9104 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'hystrixFeature' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$HystrixWebConfiguration; factoryMethodName=hystrixFeature; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration$HystrixWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration; factoryMethodName=hystrixFeature; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration.class]]
2017-03-16 16:09:10.364 WARN 9104 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-03-16 16:09:10.701 INFO 9104 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=d0eb8cfd-bd5b-3565-9f63-f671e896f6be
2017-03-16 16:09:10.736 INFO 9104 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-16 16:09:11.312 INFO 9104 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$94394ff6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-16 16:09:12.091 INFO 9104 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-03-16 16:09:12.128 INFO 9104 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-03-16 16:09:12.130 INFO 9104 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-03-16 16:09:12.546 INFO 9104 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-03-16 16:09:12.547 INFO 9104 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3699 ms
2017-03-16 16:09:13.191 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'proxyStreamServlet' to [/proxy.stream]
2017-03-16 16:09:13.193 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-03-16 16:09:13.198 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2017-03-16 16:09:13.199 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-03-16 16:09:13.199 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-03-16 16:09:13.200 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-03-16 16:09:13.200 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-03-16 16:09:13.200 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2017-03-16 16:09:13.200 INFO 9104 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-03-16 16:09:13.269 WARN 9104 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaClientApplication': Unsatisfied dependency expressed through field 'clientservice'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientService' defined in file [C:\Users\Mike\workspace\Eureka_client\target\classes\com\hello\ClientService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.netflix.discovery.DiscoveryClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2017-03-16 16:09:13.306 INFO 9104 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-03-16 16:09:13.404 INFO 9104 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-03-16 16:09:13.745 ERROR 9104 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.hello.ClientService required a bean of type 'com.netflix.discovery.DiscoveryClient' that could not be found.
Action:
Consider defining a bean of type 'com.netflix.discovery.DiscoveryClient' in your configuration.
package com.hello;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.stereotype.Service;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
#EnableDiscoveryClient
#Service
public class ClientService {
private final DiscoveryClient disc;
public ClientService(DiscoveryClient disc){
this.disc=disc;
}
#HystrixCommand(fallbackMethod="disp")
public String serviceInstancesByApplicationName(){
return this.disc.getInstancesById("a-bootiful-client").toString();
}
public String disp(){
return "This is fall back method";
}
}
package com.hello;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
#EnableHystrix
#EnableHystrixDashboard
#EnableDiscoveryClient
#SpringBootConfiguration
#EnableAutoConfiguration
#ComponentScan
#RestController
public class EurekaClientApplication {
#Autowired
private ClientService clientservice;
public static void main(String[] args) {
SpringApplication.run(EurekaClientApplication.class, args);
}
#RequestMapping("/serv")
public String serviceInstancesByApplicationName(){
return clientservice.serviceInstancesByApplicationName();
}
}
i am trying to create a simple eureka service and client program and enable hystrix on that. but i am getting this error on the code
You imported wrong DiscoveryClient class in your code. DiscoveryClient from netflix is not provided as Spring Bean. So you should use one from spring-cloud.
Try to import org.springframework.cloud.client.discovery.DiscoveryClient instead of com.netflix.discovery.DiscoveryClient in your ClientService class.
Also you need to change this.disc.getInstancesById("a-bootiful-client") to this.disc.getInstances(...).
This would be because of 2 cases.
1: The first situation is whether the imported package does not match
If you used #EnableDiscoveryClient
import org.springframework.cloud.client.discovery.DiscoveryClient
"instead of "
com.netflix.discovery.DiscoveryClient
If you used #EnableEurekaClient use this below import
import org.springframework.cloud.netflix.eureka.EnableEurekaClient
2: I did not select the starer-web dependency when I created the module, have added this below dependency in pom.xml and rebuild the project to fetch the added dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Use com.netflix.discovery.EurekaClient instead of com.netflix.discovery.DiscoveryClient. This is the discovery client provided by Netflix.
If you want to use spring discovery client then use org.springframework.cloud.client.discovery.DiscoveryClient as suggested by #yongsung.yoon
I've also faced with the same issue, I solved it after adding spring boot-starter-web dependency

Spring Boot JPA multiple datasource error

I wanted to connect my spring boot app to 2 databases . So according to a tutorial i created 2 config classes.
Config Class 1
#Configuration
#EnableTransactionManagement
#PropertySource({ "classpath:database-configs.properties" })
#EnableJpaRepositories(
basePackages = {"com.dialog.pod.ideabiz_admin.data_access_objects"},
entityManagerFactoryRef = "adminEntityManagerFactory",
transactionManagerRef = "adminTransactionManager")
public class IdeabizAdminConfig {
#Autowired
private Environment env;
#Bean
PlatformTransactionManager adminTransactionManager() {
return new JpaTransactionManager(adminEntityManagerFactory().getObject());
}
#Bean
LocalContainerEntityManagerFactoryBean adminEntityManagerFactory() {
HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
// jpaVendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(adminDataSource());
factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
factoryBean.setPackagesToScan("com.dialog.pod.ideabiz_admin.models");
factoryBean.setJpaPropertyMap(jpaProperties());
factoryBean.setPersistenceUnitName("adminDataSource");
return factoryBean;
}
#Bean
DataSource adminDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("admin.jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("admin.jdbc.url"));
dataSource.setUsername(env.getProperty("admin.jdbc.username"));
dataSource.setPassword(env.getProperty("admin.jdbc.password"));
return dataSource;
}
private Map<String, Object> jpaProperties() {
Map<String, Object> props = new HashMap<>();
props.put("hibernate.implicit_naming_strategy","org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl");
props.put("hibernate.physical_naming_strategy","com.dialog.pod.PhysicalNamingStrategyImpl");
return props;
}
}
Config Class 2
#Configuration
#EnableTransactionManagement
#PropertySource({ "classpath:database-configs.properties" })
#EnableJpaRepositories(
basePackages = {"com.dialog.pod.ideabiz_log_summary.data_access_objects"},
entityManagerFactoryRef = "sumLogEntityManagerFactory",
transactionManagerRef = "sumLogTransactionManager")
public class IdeabizLogSummaryConfig {
#Autowired
private Environment env;
#Bean
PlatformTransactionManager sumLogTransactionManager() {
return new JpaTransactionManager(sumLogEntityManagerFactory().getObject());
}
#Bean
LocalContainerEntityManagerFactoryBean sumLogEntityManagerFactory() {
HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
// jpaVendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(adminDataSource());
factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
factoryBean.setPackagesToScan("com.dialog.pod.ideabiz_log_summary.models");
factoryBean.setJpaPropertyMap(jpaProperties());
factoryBean.setPersistenceUnitName("sumLogDataSource");
return factoryBean;
}
#Bean
DataSource adminDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("sumlog.jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("sumlog.jdbc.url"));
dataSource.setUsername(env.getProperty("sumlog.jdbc.username"));
dataSource.setPassword(env.getProperty("sumlog.jdbc.password"));
return dataSource;
}
private Map<String, Object> jpaProperties() {
Map<String, Object> props = new HashMap<>();
props.put("hibernate.implicit_naming_strategy","org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl");
props.put("hibernate.physical_naming_strategy","com.dialog.pod.PhysicalNamingStrategyImpl");
return props;
}
}
Application Class
#SpringBootApplication
#EnableAutoConfiguration (exclude = { DataSourceAutoConfiguration.class })
#Configuration
#ComponentScan
public class PodApiApplication {
public static void main(String[] args) {
SpringApplication.run(PodApiApplication.class, args);
}
#Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
#Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/").allowedOrigins("*");
}
};
}
}
When i try to run the app i get following error.
***************************
APPLICATION FAILED TO START
***************************
Description:
Method requestMappingHandlerMapping in org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration required a single bean, but 2 were found:
- adminEntityManagerFactory: defined by method 'adminEntityManagerFactory' in class path resource [com/dialog/pod/ideabiz_admin/IdeabizAdminConfig.class]
- sumLogEntityManagerFactory: defined by method 'sumLogEntityManagerFactory' in class path resource [com/dialog/pod/ideabiz_log_summary/IdeabizLogSummaryConfig.class]
Action:
Consider marking one of the beans as #Primary, updating the consumer to accept multiple beans, or using #Qualifier to identify the bean that should be consumed
Process finished with exit code 1
I put #Primary to the first config class(according to another tutorial). When i do that datasource in the first config class works. Problem is when i do this first datasource also applied to all the jparepositories.
I'm new to Spring boot. I have been trying to solve this problem for over 5 hours :( . Thanks in advance for any help you are able to provide.
Full Log
2017-01-27 00:52:39.713 INFO 6704 --- [ main] com.dialog.pod.PodApiApplication : Starting PodApiApplication on DESKTOP-4B89ITN with PID 6704 (started by y2ksh in H:\Spring MVC Workspace\platform-overview-dashboard\PODApi)
2017-01-27 00:52:39.718 INFO 6704 --- [ main] com.dialog.pod.PodApiApplication : No active profile set, falling back to default profiles: default
2017-01-27 00:52:39.938 INFO 6704 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6e171cd7: startup date [Fri Jan 27 00:52:39 IST 2017]; root of context hierarchy
2017-01-27 00:52:41.712 INFO 6704 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'adminDataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=ideabizAdminConfig; factoryMethodName=adminDataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/dialog/pod/ideabiz_admin/IdeabizAdminConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=ideabizLogSummaryConfig; factoryMethodName=adminDataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/dialog/pod/ideabiz_log_summary/IdeabizLogSummaryConfig.class]]
2017-01-27 00:52:42.804 INFO 6704 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3cc0fc3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-01-27 00:52:43.594 INFO 6704 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8081 (http)
2017-01-27 00:52:43.609 INFO 6704 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-01-27 00:52:43.609 INFO 6704 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-01-27 00:52:43.810 INFO 6704 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-01-27 00:52:43.810 INFO 6704 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3891 ms
2017-01-27 00:52:44.247 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-01-27 00:52:44.253 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricFilter' to: [/*]
2017-01-27 00:52:44.254 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-01-27 00:52:44.254 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-01-27 00:52:44.254 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-01-27 00:52:44.254 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-01-27 00:52:44.255 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2017-01-27 00:52:44.255 INFO 6704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-01-27 00:52:44.367 INFO 6704 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2017-01-27 00:52:44.403 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'adminDataSource'
2017-01-27 00:52:44.435 INFO 6704 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: adminDataSource
...]
2017-01-27 00:52:44.634 INFO 6704 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2017-01-27 00:52:44.636 INFO 6704 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-01-27 00:52:44.641 INFO 6704 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-01-27 00:52:44.725 INFO 6704 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-01-27 00:52:45.302 INFO 6704 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-01-27 00:52:46.178 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'adminDataSource'
2017-01-27 00:52:46.189 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'sumLogDataSource'
2017-01-27 00:52:46.190 INFO 6704 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: sumLogDataSource
...]
2017-01-27 00:52:46.228 INFO 6704 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-01-27 00:52:46.291 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'sumLogDataSource'
2017-01-27 00:52:46.695 INFO 6704 --- [ main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2017-01-27 00:52:46.947 INFO 6704 --- [ main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2017-01-27 00:52:47.496 INFO 6704 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6e171cd7: startup date [Fri Jan 27 00:52:39 IST 2017]; root of context hierarchy
2017-01-27 00:52:47.560 WARN 6704 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openEntityManagerInViewInterceptor' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration$JpaWebConfiguration$JpaWebMvcConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available: expected single matching bean but found 2: adminEntityManagerFactory,sumLogEntityManagerFactory
2017-01-27 00:52:47.562 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'sumLogDataSource'
2017-01-27 00:52:47.563 INFO 6704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'adminDataSource'
2017-01-27 00:52:47.566 INFO 6704 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-01-27 00:52:47.586 INFO 6704 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-01-27 00:52:47.592 ERROR 6704 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Method requestMappingHandlerMapping in org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration required a single bean, but 2 were found:
- adminEntityManagerFactory: defined by method 'adminEntityManagerFactory' in class path resource [com/dialog/pod/ideabiz_admin/IdeabizAdminConfig.class]
- sumLogEntityManagerFactory: defined by method 'sumLogEntityManagerFactory' in class path resource [com/dialog/pod/ideabiz_log_summary/IdeabizLogSummaryConfig.class]
Action:
Consider marking one of the beans as #Primary, updating the consumer to accept multiple beans, or using #Qualifier to identify the bean that should be consumed
Process finished with exit code 1
Mark one of the beans as primary
#Primary
#Bean
public EntityManagerFactory entityManagerFactory() {
}
Your Spring Boot application implicitly activates Spring Web Mvc via #WebMvcAutoConfiguration which is triggered by having, among others, Servlet.class in your class path. This #WebMvcAutoConfiguration requires a bean of type EntityManagerFactory. However, you have registered two such beans adminEntityManagerFactory and sumLogEntityManagerFactory. So you have to tell Spring Web Mvc which is your preferred one via #Primary on top of the respective #Bean method. Alternatively if you don't need Web Mvc autoconfiguration switch it off by #EnableAutoConfiguration(exclude={WebMvcAutoConfiguration}) and configure Web Mvc manually.
It turns out i used same method name for both datasource beans . This was the reason why only one data source used for all jparepos. Thanks #Javatar81 for explaining how bean naming works

Spring #ComponentScan isn't picked up, maybe due to #EnableAutoConfiguration in #SpringBootApplication?

i'm new to SpringBoot and am currently reaching to understand the base functionality for a spring application with hibernate.
I have a package com.yyyyyyyyyyy.coaching and if I put all #Entity definitions there the app runs successfully. I was happy to get up and running quick.
Now I moved one entity to com.yyyyyyyyyyy.i18n.bo since it should later be used elsewhere and hibernate throws the following error:
Caused by: org.hibernate.AnnotationException: #OneToOne or #ManyToOne on com.yyyyyyyyyyy.coaching.bo.Topic.descriptionStrings references an unknown entity: com.yyyyyyyyyyy.i18n.bo.Localized
(see below for the full --debug application startup)
I understand that #ComponentScan should be used to specify which packages are scanned for annotations.
I have double checked that javax.persistence.Entity is used everywhere and not the one from the hibernate package.
Here is my program entry point:
#SpringBootApplication(scanBasePackages={"com.yyyyyyyyyyy"})
//#Configuration
//#ComponentScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})
#Import(AppConfig.class)
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
It doesn't find the Entity with scanBasePackages, with ComponentScan on the main class and also when using #Import and another config class "AppConfig". I also tried to use the ApplicationBuilder instead of SpringApplication like this new SpringApplicationBuilder().sources(AppConfig.class).main(DemoApplication.class).run(args); but to no avail.
What I can see from the debug output is the line:
2015-11-18 08:08:48.407 DEBUG 13780 --- [ main] o.s.b.a.AutoConfigurationPackages : #EnableAutoConfiguration was declared on a class in the package 'com.yyyyyyyyyyy.coaching'. Automatic #Repository and #Entity scanning is enabled.
I suppose this doesn't hurt as it comes from the #SpringBootApplication annotation
The AppConfig class doesn't seem to be included either, as I added debug output which isn't printed.
#Configuration
//#Profile("production")
#ComponentScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})
public class AppConfig {
public AppConfig() {
System.out.println("------------------------------Init AppConfig-------------------------");
}
#PostConstruct
public void doSomething() {
System.out.println("------------------------------Done AppConfig-------------------------");
}
}
Any help/ideas on this?
Thanks.
Edit, prj structure:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.0.RELEASE)
2015-11-18 08:08:47.048 INFO 13780 --- [ main] c.yyyyyyyyyyy.coaching.DemoApplication : Starting DemoApplication on Suse with PID 13780 (started by Klaus in C:\Users\Klaus\Downloads\demo (1)\demo)
2015-11-18 08:08:47.051 INFO 13780 --- [ main] c.yyyyyyyyyyy.coaching.DemoApplication : No profiles are active
2015-11-18 08:08:47.051 DEBUG 13780 --- [ main] o.s.boot.SpringApplication : Loading source class com.yyyyyyyyyyy.coaching.DemoApplication
2015-11-18 08:08:47.098 DEBUG 13780 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'classpath:/application.properties'
2015-11-18 08:08:47.098 DEBUG 13780 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped (empty) config file 'classpath:/application.properties' for profile default
2015-11-18 08:08:47.103 INFO 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1fc32e4f: startup date [Wed Nov 18 08:08:47 CET 2015]; root of context hierarchy
2015-11-18 08:08:47.106 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1fc32e4f: org.springframework.beans.factory.support.DefaultListableBeanFactory#7a1a3478: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,demoApplication]; root of factory hierarchy
2015-11-18 08:08:48.286 INFO 13780 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-11-18 08:08:48.407 DEBUG 13780 --- [ main] o.s.b.a.AutoConfigurationPackages : #EnableAutoConfiguration was declared on a class in the package 'com.yyyyyyyyyyy.coaching'. Automatic #Repository and #Entity scanning is enabled.
2015-11-18 08:08:48.995 INFO 13780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$4e01ef7c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-11-18 08:08:49.038 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource#2e17a321]
2015-11-18 08:08:49.038 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster#521bb1a4]
2015-11-18 08:08:49.368 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\Klaus\.m2\repository\org\springframework\boot\spring-boot\1.3.0.RELEASE\spring-boot-1.3.0.RELEASE.jar
2015-11-18 08:08:49.369 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\Klaus\.m2\repository\org\springframework\boot\spring-boot\1.3.0.RELEASE\spring-boot-1.3.0.RELEASE.jar
2015-11-18 08:08:49.369 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2015-11-18 08:08:49.419 INFO 13780 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-11-18 08:08:49.433 INFO 13780 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-11-18 08:08:49.434 INFO 13780 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.28
2015-11-18 08:08:49.566 INFO 13780 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-11-18 08:08:49.566 INFO 13780 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2467 ms
[..]
2015-11-18 08:08:49.960 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-11-18 08:08:49.960 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-11-18 08:08:49.961 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2015-11-18 08:08:49.961 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2015-11-18 08:08:49.982 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.web.OrderedRequestContextFilter : Initializing filter 'requestContextFilter'
2015-11-18 08:08:49.984 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.web.OrderedRequestContextFilter : Filter 'requestContextFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] .s.b.c.w.OrderedHttpPutFormContentFilter : Initializing filter 'httpPutFormContentFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] .s.b.c.w.OrderedHttpPutFormContentFilter : Filter 'httpPutFormContentFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedHiddenHttpMethodFilter : Initializing filter 'hiddenHttpMethodFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedHiddenHttpMethodFilter : Filter 'hiddenHttpMethodFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedCharacterEncodingFilter : Initializing filter 'characterEncodingFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedCharacterEncodingFilter : Filter 'characterEncodingFilter' configured successfully
2015-11-18 08:08:50.825 INFO 13780 --- [ main] liquibase : Successfully acquired change log lock
2015-11-18 08:08:50.917 INFO 13780 --- [ main] liquibase : Reading from broadleaf.DATABASECHANGELOG
2015-11-18 08:08:50.926 INFO 13780 --- [ main] liquibase : Successfully released change log lock
2015-11-18 08:08:51.116 INFO 13780 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-11-18 08:08:51.128 INFO 13780 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-11-18 08:08:51.210 INFO 13780 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}
2015-11-18 08:08:51.211 INFO 13780 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-11-18 08:08:51.214 INFO 13780 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-11-18 08:08:51.394 INFO 13780 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-11-18 08:08:51.441 INFO 13780 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2015-11-18 08:08:51.557 WARN 13780 --- [ 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
2015-11-18 08:08:51.567 INFO 13780 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2015-11-18 08:08:51.574 INFO 13780 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [ ...
2015-11-18 08:08:51.578 ERROR 13780 --- [ 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:1578) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1051) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:828) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at com.yyyyyyyyyyy.coaching.DemoApplication.main(DemoApplication.java:23) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.AnnotationException: #OneToOne or #ManyToOne on com.yyyyyyyyyyy.coaching.bo.Topic.descriptionStrings references an unknown entity: com.yyyyyyyyyyy.i18n.bo.Localized
Move DemoApplication class to com.yyyyyyyyyyy package and everything should work. Everything which is in com.yyyyyyyyyyy should be picked automatically.
Check this out how spring boot recommend structuring
UPDATE:
also as you saw in the ref documentation add
add #EntityScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})to DemoApplication will work.

Resources