Errors creating multiple database entities in Spring/hibernate - java

Attempting to make a spring application with multiple databases in spring-boot. MY orm is hibernate and below I have a copy of my application.properties files and my print trace. Thanks for any help in advance:
spring.ds_toner.url = jdbc:mysql://localhost:3306/toner_stock?useSSL=false
spring.ds_toner.username=toner
spring.ds_toner.password=toner
spring.ds_toner.driver-class-name=com.mysql.jdbc.Driver
spring.ds_manager.url=jdbc:mysql://localhost:3306/toner_manager?useSSL=false
spring.ds_manager.username=toner
spring.ds_manager.password=toner
spring.ds_manager.driver-class-name= com.mysql.jdbc.Driver
spring.ds_buyer.url= jdbc:mysql://localhost:3306/toner_buyer?useSSL=false
spring.ds_buyer.username=toner
spring.ds_buyer.password=toner
spring.ds_buyer.driver-class-name= com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
spring.jpa.hibernate.dialect= org.hibernate.dialect.MySQL55Dialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
Print Trace:
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=52449:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Users/ronaldpitt/Desktop/TonerStock/target/classes:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.2.RELEASE/spring-boot-starter-web-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.2.RELEASE/spring-boot-starter-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot/1.5.2.RELEASE/spring-boot-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.2.RELEASE/spring-boot-autoconfigure-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.2.RELEASE/spring-boot-starter-logging-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/Users/ronaldpitt/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/jul-to-slf4j/1.7.24/jul-to-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.24/log4j-over-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.2.RELEASE/spring-boot-starter-tomcat-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-validator/5.3.4.Final/hibernate-validator-5.3.4.Final.jar:/Users/ronaldpitt/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-web/4.3.7.RELEASE/spring-web-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-webmvc/4.3.7.RELEASE/spring-webmvc-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-thymeleaf/1.5.2.RELEASE/spring-boot-starter-thymeleaf-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf-spring4/2.1.5.RELEASE/thymeleaf-spring4-2.1.5.RELEASE.jar:/Users/ronaldpitt/.m2/repository/nz/net/ultraq/thymeleaf/thymeleaf-layout-dialect/1.4.0/thymeleaf-layout-dialect-1.4.0.jar:/Users/ronaldpitt/.m2/repository/org/codehaus/groovy/groovy/2.4.9/groovy-2.4.9.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-core/5.2.9.Final/hibernate-core-5.2.9.Final.jar:/Users/ronaldpitt/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/Users/ronaldpitt/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/Users/ronaldpitt/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/ronaldpitt/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.1.Final/jboss-transaction-api_1.2_spec-1.0.1.Final.jar:/Users/ronaldpitt/.m2/repository/org/jboss/jandex/2.0.3.Final/jandex-2.0.3.Final.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/Users/ronaldpitt/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/Users/ronaldpitt/.m2/repository/org/springframework/data/spring-data-commons/1.13.1.RELEASE/spring-data-commons-1.13.1.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.24/jcl-over-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.5.2.RELEASE/spring-boot-starter-data-jpa-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.5.2.RELEASE/spring-boot-starter-aop-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.5.2.RELEASE/spring-boot-starter-jdbc-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.5.11/tomcat-jdbc-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/tomcat-juli/8.5.11/tomcat-juli-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-jdbc/4.3.7.RELEASE/spring-jdbc-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar:/Users/ronaldpitt/.m2/repository/org/springframework/data/spring-data-jpa/1.11.1.RELEASE/spring-data-jpa-1.11.1.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-orm/4.3.7.RELEASE/spring-orm-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-tx/4.3.7.RELEASE/spring-tx-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-aspects/4.3.7.RELEASE/spring-aspects-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/mysql/mysql-connector-java/5.1.39/mysql-connector-java-5.1.39.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-entitymanager/5.2.9.Final/hibernate-entitymanager-5.2.9.Final.jar:/Users/ronaldpitt/.m2/repository/net/bytebuddy/byte-buddy/1.6.6/byte-buddy-1.6.6.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf-spring3/3.0.3.RELEASE/thymeleaf-spring3-3.0.3.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf/2.1.5.RELEASE/thymeleaf-2.1.5.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/unbescape/unbescape/1.1.0.RELEASE/unbescape-1.1.0.RELEASE.jar com.ronone.Application
objc[6848]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (0x10eb834c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1103f14e0). One of the two will be used. Which one is undefined.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
2017-05-11 21:12:08.760 INFO 6848 --- [ main] com.ronone.Application : Starting Application on Ronalds-MacBook-Pro.local with PID 6848 (/Users/ronaldpitt/Desktop/TonerStock/target/classes started by ronaldpitt in /Users/ronaldpitt/Desktop/TonerStock)
2017-05-11 21:12:08.763 INFO 6848 --- [ main] com.ronone.Application : No active profile set, falling back to default profiles: default
2017-05-11 21:12:09.015 INFO 6848 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#77be656f: startup date [Thu May 11 21:12:09 EDT 2017]; root of context hierarchy
2017-05-11 21:12:10.645 INFO 6848 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$578c281f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-05-11 21:12:11.075 INFO 6848 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-05-11 21:12:11.108 INFO 6848 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-05-11 21:12:11.110 INFO 6848 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-05-11 21:12:11.267 INFO 6848 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-05-11 21:12:11.267 INFO 6848 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2258 ms
2017-05-11 21:12:11.465 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-05-11 21:12:11.471 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-05-11 21:12:11.472 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-05-11 21:12:11.473 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-05-11 21:12:11.473 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-05-11 21:12:11.532 WARN 6848 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': 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$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2017-05-11 21:12:11.534 INFO 6848 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-05-11 21:12:11.547 WARN 6848 --- [ost-startStop-1] 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:143)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2017-05-11 21:12:11.561 INFO 6848 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-11 21:12:11.569 ERROR 6848 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

The reason for the exception is
Cannot determine embedded database driver class for database type NONE.
If you want an embedded database please put a supported one on the
classpath. If you have database settings to be loaded from a particular
profile you may need to active it (no profiles are currently active).
Spring autoconfiguration is creating only one DataSource and expects properties as
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring boot reference
You do not set these properties, so spring tries to create a datasource without url, which leads to the exception.
You need to create additional DataSources yourself, you may find this post helpfull.

Related

Injecting JdbcOperationsSessionRepository into a constructor

I'm upgrading a SpringBoot app from 2.1.17 to 2.3.4, which includes this class:
#Configuration
public class SessionRepositoryConfig {
public SessionRepositoryConfig(JdbcOperationsSessionRepository sessionRepo) {
// configure session expiry + table name + converter
...
...
}
}
This is the only mention of JdbcOperationsSessionRepository in the entire code-base, so presumably in 2.1.17 a bean of this type was automatically made available by SpringBoot. However, when I switch to 2.3.4 the injection fails:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-10-13 12:32:43.970 INFO --- [kground-preinit] o.h.v.i.u.Version : HV000001: Hibernate Validator 6.1.2.Final
2020-10-13 12:32:44.082 INFO --- [ main] c.s.o.a.s.UIAuthorizationEndpointTest : Starting UIAuthorizationEndpointTest on UK-WMorgan1 with PID 17444 (started by WMorgan in C:\git_repos\oauth2-auth-server\sc-oauth2-authorization-server-application)
2020-10-13 12:32:44.086 INFO --- [ main] c.s.o.a.s.UIAuthorizationEndpointTest : The following profiles are active: local,dbAutoUpdate,localLDAP
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/wmorgan/.m2/repository/org/codehaus/groovy/groovy/2.5.13/groovy-2.5.13.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
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
2020-10-13 12:32:47.823 INFO --- [ main] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 0 (http)
2020-10-13 12:32:47.848 INFO --- [ main] o.a.c.h.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-auto-1"]
2020-10-13 12:32:47.849 INFO --- [ main] o.a.c.c.StandardService : Starting service [Tomcat]
2020-10-13 12:32:47.849 INFO --- [ main] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-10-13 12:32:48.046 INFO --- [ main] o.a.c.c.C.[.[.[/oauth2Server] : Initializing Spring embedded WebApplicationContext
2020-10-13 12:32:48.046 INFO --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3561 ms
2020-10-13 12:32:48.444 INFO --- [ main] c.t.c.c.f.KeyStoreFactoryBean : Loading key store from URL [file:./src/test/resources/thunderhead.jks]
2020-10-13 12:32:48.809 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Starting...
2020-10-13 12:32:49.120 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Start completed.
2020-10-13 12:32:50.376 WARN --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryConfiguration' defined in file [C:\git_repos\oauth2-auth-server\sc-oauth2-authorization-server-application\target\classes\com\SessionRepositoryConfig.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.springframework.session.jdbc.JdbcOperationsSessionRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-10-13 12:32:50.377 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-10-13 12:32:50.385 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-10-13 12:32:50.393 INFO --- [ main] o.a.c.c.StandardService : Stopping service [Tomcat]
2020-10-13 12:32:50.410 INFO --- [ main] ConditionEvaluationReportLoggingListener :
What's the simplest way I can get this working again?
Fixed by replacing JdbcOperationsSessionRepository with JdbcIndexedSessionRepository

Cant add data to databases on Spring Boot using Heroku postgres

I've been trying to get a Rest Repository up and running using Heroku. However, while the tables I'm using are being added to the datasource, I am unable to upload any rows of data.
Shows that my tables are being added to postgres datasource
I don't get any error messages or issues deploying the service, I just can't add data.
I've looked around the internet for solutions currently application.properties is a mess of different bits of code that I've copied on all the guides for how to get a database running.
#spring.h2.console.enabled=true
#spring.datasource.url=jdbc:h2:mem:testdb
#spring.datasource.driverClassName=org.h2.Driver
#spring.datasource.username=sa
#spring.datasource.password=
#spring.h2.console.settings.web-allow-others=true
#spring.main.banner-mode=off
#logging.level.org.springframework=ERROR
spring.jpa.hibernate.ddl-auto=update
#spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
#spring.datasource.url=postgres://npwovtbfrmcgap:8cb0a1d61d6608e756d4340bb79926156b43c5d602580ab21884d058b7adf230#ec2-52-23-14-156.compute-1.amazonaws.com:5432/deu5uhuf0in93s
#spring.datasource.url=${JDBC_DATABASE_URL}
#spring.datasource.username=${SPRING_DATABASE_USERNAME}
#spring.datasource.password=${SPRING_DATABASE_PASSWORD}
#spring.jpa.show-sql=true
#spring.jpa.generate-ddl=true
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
spring.jpa.show-sql=false
spring.jpa.generate-ddl=true
For testing I used h2 and that worked fine with no issues. Even though I've been eyeing using JDBC _DATABASE for it's easy setup, I've made a Database Configuration file.
package com.example.chess.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
#Configuration
public class DatabaseConfig {
#Bean
#Primary
#ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource()
{
return new org.apache.tomcat.jdbc.pool.DataSource();
}
}
There isn't a whole lot here, but from my understanding I shouldn't need one if I'm using a JDBC Database.
Some ideas that I have...
Heroku could be forcing me to use their guide on preparing a Spring Boot App for production
https://devcenter.heroku.com/articles/preparing-a-spring-boot-app-for-production-on-heroku
I could put better #GeneratedValue typing on the code for tables I have.
package com.example.chess.Model;
import javax.persistence.*;
#Entity
public class Chat {
#GeneratedValue
#Id
#Column
private int chatID;
#Column
private String chatMsg;
public int getChatID() {
return chatID;
}
public String getChatMsg() {
return chatMsg;
}
public void setChatID(int chatID) {
this.chatID = chatID;
}
public void setChatMsg(String chatMsg) {
this.chatMsg = chatMsg;
}
}
Past that I'm not really sure what to do. Any feedback is appreciated.
Thanks for all the help, however I still havent gotten it working. I used heroku logs to find more data. I also used spring.database.platform and spring.datasource.driver-class-name. the code for application properties has been updated.
2020-02-18T02:22:38.000000+00:00 app[api]: Build succeeded
2020-02-18T02:22:41.021726+00:00 app[web.1]: 2020-02-18 02:22:41.017 INFO 4 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:41.264675+00:00 app[web.1]:
2020-02-18T02:22:41.264732+00:00 app[web.1]: . ____ _ __ _ _
2020-02-18T02:22:41.264786+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2020-02-18T02:22:41.264849+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-02-18T02:22:41.264905+00:00 app[web.1]: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2020-02-18T02:22:41.264972+00:00 app[web.1]: ' |____| .__|_| |_|_| |_\__, | / / / /
2020-02-18T02:22:41.265009+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-02-18T02:22:41.265886+00:00 app[web.1]: :: Spring Boot :: (v2.1.7.RELEASE)
2020-02-18T02:22:41.265938+00:00 app[web.1]:
2020-02-18T02:22:41.335856+00:00 app[web.1]: 2020-02-18 02:22:41.335 INFO 4 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-18T02:22:41.566210+00:00 app[web.1]: 2020-02-18 02:22:41.565 INFO 4 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2020-02-18T02:22:41.566423+00:00 app[web.1]: 2020-02-18 02:22:41.566 WARN 4 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2020-02-18T02:22:41.570798+00:00 app[web.1]: 2020-02-18 02:22:41.570 INFO 4 --- [ main] com.example.chess.ChessApplication : No active profile set, falling back to default profiles: default
2020-02-18T02:22:42.945648+00:00 app[web.1]: 2020-02-18 02:22:42.943 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-02-18T02:22:43.135659+00:00 app[web.1]: 2020-02-18 02:22:43.135 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 157ms. Found 4 repository interfaces.
2020-02-18T02:22:43.711365+00:00 app[web.1]: 2020-02-18 02:22:43.711 INFO 4 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=de70dafe-40e0-316f-93ef-ef4b324ee017
2020-02-18T02:22:43.965692+00:00 app[web.1]: 2020-02-18 02:22:43.965 INFO 4 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cdb9cd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.025903+00:00 app[web.1]: 2020-02-18 02:22:44.025 INFO 4 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.561043+00:00 app[web.1]: 2020-02-18 02:22:44.560 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 37710 (http)
2020-02-18T02:22:44.670131+00:00 app[web.1]: 2020-02-18 02:22:44.669 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-02-18T02:22:44.670471+00:00 app[web.1]: 2020-02-18 02:22:44.670 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.22]
2020-02-18T02:22:45.421352+00:00 app[web.1]: 2020-02-18 02:22:45.421 INFO 4 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-02-18T02:22:45.421626+00:00 app[web.1]: 2020-02-18 02:22:45.421 INFO 4 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3826 ms
2020-02-18T02:22:45.859027+00:00 app[web.1]: 2020-02-18 02:22:45.858 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-02-18T02:22:46.292693+00:00 app[web.1]: 2020-02-18 02:22:46.292 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-02-18T02:22:46.414129+00:00 app[web.1]: 2020-02-18 02:22:46.413 INFO 4 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
2020-02-18T02:22:46.414131+00:00 app[web.1]: name: default
2020-02-18T02:22:46.414131+00:00 app[web.1]: ...]
2020-02-18T02:22:46.563652+00:00 app[web.1]: 2020-02-18 02:22:46.563 INFO 4 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.10.Final}
2020-02-18T02:22:46.566628+00:00 app[web.1]: 2020-02-18 02:22:46.566 INFO 4 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-02-18T02:22:46.824490+00:00 app[web.1]: 2020-02-18 02:22:46.824 INFO 4 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2020-02-18T02:22:47.331763+00:00 app[web.1]: 2020-02-18 02:22:47.331 INFO 4 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-02-18T02:22:47.616894+00:00 app[web.1]: 2020-02-18 02:22:47.616 INFO 4 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true
2020-02-18T02:22:47.624236+00:00 app[web.1]: 2020-02-18 02:22:47.623 INFO 4 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#37e4d7bb
2020-02-18T02:22:48.869877+00:00 app[web.1]: 2020-02-18 02:22:48.869 INFO 4 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-18T02:22:49.329464+00:00 app[web.1]: 2020-02-18 02:22:49.329 INFO 4 --- [ main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2020-02-18T02:22:50.308149+00:00 app[web.1]: 2020-02-18 02:22:50.307 INFO 4 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-18T02:22:50.411820+00:00 app[web.1]: 2020-02-18 02:22:50.409 WARN 4 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-18T02:22:50.461378+00:00 app[web.1]: 2020-02-18 02:22:50.461 INFO 4 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2020-02-18T02:22:51.073701+00:00 heroku[web.1]: State changed from starting to up
2020-02-18T02:22:50.863588+00:00 app[web.1]: 2020-02-18 02:22:50.863 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 37710 (http) with context path ''
2020-02-18T02:22:50.865846+00:00 app[web.1]: 2020-02-18 02:22:50.865 INFO 4 --- [ main] com.example.chess.ChessApplication : Started ChessApplication in 12.027 seconds (JVM running for 12.976)
Try adding dialect , driver-class name and database-platform as you have commented those.
Finally fixed it. Boy do I feel dumb, the problem was in the angular frontend I was posting and getting from localhost:8080.
$http.get("http://localhost:8080/letter").then(function (response){
$scope.letter = response.data;
});
$scope.postLetter = function(letter)
{
var data = {
contactName: contactName,
email: email,
message: message
};
$http.post("http://localhost:8080/letter", JSON.stringify(data));
location.reload();
};
Thanks again for everyone who tried helping.

Update your application's configuration in Spring Boot

Update your application's configuration in Spring Boot error when I am running a Spring Boot Application.
The maven is built successfully, but still the error persists.
What should I do to change overcome this error?
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M4)
2018-06-08 12:45:36.422 INFO 8904 --- [ main] com.lankydan.Application : Starting Application on GH-6C9HNH2 with PID 8904 (C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master\target\classes started by E080978 in C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master)
2018-06-08 12:45:36.426 INFO 8904 --- [ main] com.lankydan.Application : No active profile set, falling back to default profiles: default
2018-06-08 12:45:36.484 INFO 8904 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2805c96b: startup date [Fri Jun 08 12:45:36 IST 2018]; root of context hierarchy
2018-06-08 12:45:37.897 INFO 8904 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3a19c841] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-08 12:45:38.652 INFO 8904 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
2018-06-08 12:45:38.672 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-08 12:45:38.673 INFO 8904 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2337 ms
2018-06-08 12:45:39.020 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-08 12:45:39.075 WARN 8904 --- [ 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.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties': prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String
2018-06-08 12:45:39.077 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-06-08 12:45:39.098 INFO 8904 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-08 12:45:39.103 ERROR 8904 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target [Bindable#6bff19ff type = java.lang.String, value = 'provided', annotations = array<Annotation>[[empty]]] failed:
Property: spring.datasource.password
Value: ${password}
Origin: class path resource [application.properties]:7:28
Reason: Could not resolve placeholder 'password' in value "${password}"
Action:
Update your application's configuration
You have to turn on filtering for your maven resources plugin. You have to add a <filtering> tag to your POM and set it to true.
The ${password} variable possibly needs to be replaced with the real password by maven, during the "process resources" phase
For further info see:
https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
It looks like you have not declared the property 'password' (or there's something wrong with it's declaration) that you're trying to use in 'spring.datasource.password' property.
It's hard to tell, though, without seeing the whole properties file.
The error is because your application can't find the env variable password. If this problem only happens on you local machine, simply specify a default value when the env var is not present. Like this:
spring.datasource.password: ${password:local-password}
(Change local-password to the real password of your local database.)
If it happens in your test or prod environment, you have to inject it into your server's environment variables, or contact the DevOps guy to help you do that.
In my case removing below from pom.xml fixed the issue
<resources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources/</directory>
<targetPath>${project.build.directory}/config/</targetPath>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>

Spring Accessing data with MySQL Won't Run

I'm new to using Spring, and I'm going through the accessing-data-with-MySQL tutorial here. I'm using Eclipse, and when I download all the code for the project, and then run the project as a Spring Boot App, I get the error:
APPLICATION FAILED TO START
Description:
Field userRepository in hello.MainController required a bean of type 'hello.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'hello.UserRepository' in your configuration.
Again, this is the code directly from the tutorial. Anybody have any idea what's going on?
Thanks!
Full run log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-08-26 21:58:28.365 INFO 2308 --- [ main] hello.Application : Starting Application on DESKTOP-F9F09K7 with PID 2308 (C:\Users\dylan\Desktop\gs-accessing-data-mysql-master\complete\target\classes started by dylan in C:\Users\dylan\Desktop\gs-accessing-data-mysql-master\complete)
2017-08-26 21:58:28.367 INFO 2308 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2017-08-26 21:58:28.411 INFO 2308 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6b53e23f: startup date [Sat Aug 26 21:58:28 PDT 2017]; root of context hierarchy
2017-08-26 21:58:29.454 INFO 2308 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-08-26 21:58:29.465 INFO 2308 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-08-26 21:58:29.466 INFO 2308 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-26 21:58:29.542 INFO 2308 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-08-26 21:58:29.542 INFO 2308 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1135 ms
2017-08-26 21:58:29.655 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-26 21:58:29.659 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-26 21:58:29.701 WARN 2308 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'hello.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2017-08-26 21:58:29.703 INFO 2308 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-08-26 21:58:29.721 INFO 2308 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-08-26 21:58:29.804 ERROR 2308 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userRepository in hello.MainController required a bean of type 'hello.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'hello.UserRepository' in your configuration.
I was able to fix this problem by clearing my maven cache. I did this by manually deleting my:
C:\Users\username\ .m2
folder and then doing a clean install. What the problem was, how it developed, and what changed to fix it I/we may never know. But, things seem to be working again.
Thanks to all who helped!
Have you registered a repository with type UserRepository? Check if you sign the repository with a #Repository annotation.
Download project from git gs-accessing-data-mysql-master
Extract the file to your disk
Open Eclipse
Click File > Import > Existing Maven Projects > Next
Click Browse and select the gs-accessing-data-mysql-master folder that is on your disk and Next
Select both pom.xml and Finish
Open gs-mysql-data project that has been imported
Right click on Application.java and run as Java Application or Spring Boot Application
Make sure that UserRepository interface extends from CrudRepository, like this:
package hello;
import org.springframework.data.repository.CrudRepository;
import hello.User;
// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete
public interface UserRepository extends CrudRepository<User, Long> {
}

Simplified Spring Bookmark tutorial fails to instantiate my repository bean

I've tried to make an ultra-simplified version of the Spring Bookmark tutorial (using gradle rather than maven). My code can be found here: https://github.com/JetForMe/spring-hoa/tree/master/src/main/java/com/latencyzero/hoa
Among the changes I made was to call "User" what the tutorial calls "Account," and minor stylistic changes that I don't think are causing the problem, but they might be, if it's a name-matching issue (but I think Spring is smart enough to look for types).
In any case, my UserRepository class is not getting instantiated, and therefore not auto-wiring up to the rest of my classes. Poring over the tutorial, I don't see any special effort to instantiate the repositories.
The log shows something that might be a red herring: "Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.latencyzero.hoa.UserRepository."
Here's the full log:
$ gradle bootRun
:compileJava
:processResources
:classes
:findMainClass
:bootRun
2016-10-25 02:53:00.108 INFO 99423 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3f1dba7: startup date [Tue Oct 25 02:53:00 PDT 2016]; root of context hierarchy
2016-10-25 02:53:00.376 INFO 99423 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8758e0b1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.1.RELEASE)
2016-10-25 02:53:00.593 INFO 99423 --- [ restartedMain] com.latencyzero.hoa.Application : No active profile set, falling back to default profiles: default
2016-10-25 02:53:00.605 INFO 99423 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ae0374c: startup date [Tue Oct 25 02:53:00 PDT 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#3f1dba7
2016-10-25 02:53:01.873 INFO 99423 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'ignoredPathsWebSecurityConfigurerAdapter' 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.security.SpringBootWebSecurityConfiguration; factoryMethodName=ignoredPathsWebSecurityConfigurerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration; factoryMethodName=ignoredPathsWebSecurityConfigurerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfiguration.class]]
2016-10-25 02:53:02.047 INFO 99423 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2016-10-25 02:53:02.069 INFO 99423 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.latencyzero.hoa.UserRepository.
2016-10-25 02:53:02.150 WARN 99423 --- [ restartedMain] 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'.
2016-10-25 02:53:02.367 INFO 99423 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=ca9236f5-9f66-359b-bc2d-0d19b66d24be
2016-10-25 02:53:02.485 INFO 99423 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$6b3eddb4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-25 02:53:02.530 INFO 99423 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8758e0b1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-25 02:53:02.980 INFO 99423 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-10-25 02:53:02.991 INFO 99423 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-10-25 02:53:02.992 INFO 99423 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2016-10-25 02:53:03.076 INFO 99423 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-10-25 02:53:03.076 INFO 99423 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2471 ms
2016-10-25 02:53:03.414 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2016-10-25 02:53:03.414 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-25 02:53:03.414 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-25 02:53:03.415 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-25 02:53:03.415 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-25 02:53:03.416 INFO 99423 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2016-10-25 02:53:03.417 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2016-10-25 02:53:03.417 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2016-10-25 02:53:03.417 INFO 99423 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-25 02:53:03.457 WARN 99423 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController' defined in file [/Users/rmann/Projects/HOA/spring-hoa/build/classes/main/com/latencyzero/hoa/UserController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [com.latencyzero.hoa.UserRepository]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2016-10-25 02:53:03.460 INFO 99423 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service Tomcat
2016-10-25 02:53:03.472 WARN 99423 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: Factory method 'transactionAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2016-10-25 02:53:03.641 ERROR 99423 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.latencyzero.hoa.UserController required a bean of type 'com.latencyzero.hoa.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'com.latencyzero.hoa.UserRepository' in your configuration.
BUILD SUCCESSFUL
Total time: 11.941 secs
Any idea what I overlooked? Thanks!
Okay, it turns out I was missing some dependencies. I added spring-boot-starter-data-jpa, and h2. Now I'm getting a different error, but I'll post a new question about that.

Categories

Resources