. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2017-04-25 20:13:52.771 INFO 6852 --- [ main] com.example.SpringDemoApplication : Starting SpringDemoApplication on northwedding66 with PID 6852 (D:\java\daima\spring-demo\target\classes started by Administrator in D:\java\daima\spring-demo)
2017-04-25 20:13:52.774 INFO 6852 --- [ main] com.example.SpringDemoApplication : No active profile set, falling back to default profiles: default
2017-04-25 20:13:52.864 INFO 6852 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@fdefd3f: startup date [Tue Apr 25 20:13:52 GMT+08:00 2017]; root of context hierarchy
2017-04-25 20:13:54.016 INFO 6852 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2017-04-25 20:13:54.037 INFO 6852 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.example.UserDao.
2017-04-25 20:13:54.052 INFO 6852 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2017-04-25 20:13:54.064 INFO 6852 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.UserDao.
2017-04-25 20:13:54.684 INFO 6852 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$bb5a6e5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-04-25 20:13:54.743 INFO 6852 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2017-04-25 20:13:55.221 INFO 6852 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9090 (http)
2017-04-25 20:13:55.244 INFO 6852 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-04-25 20:13:55.245 INFO 6852 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-04-25 20:13:55.438 INFO 6852 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-04-25 20:13:55.439 INFO 6852 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2580 ms
2017-04-25 20:13:55.697 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-04-25 20:13:55.699 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'messageDispatcherServlet' to [/services/*]
2017-04-25 20:13:55.706 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-04-25 20:13:55.707 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-04-25 20:13:55.707 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-04-25 20:13:55.709 INFO 6852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-04-25 20:13:55.764 WARN 6852 --- [ 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.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2017-04-25 20:13:55.767 INFO 6852 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-04-25 20:13:55.781 WARN 6852 --- [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:41)
2017-04-25 20:13:55.793 INFO 6852 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-04-25 20:13:55.928 ERROR 6852 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'
Action:
Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.
Connecté à MySQL et changé le pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Ensuite, voici l'application
spring.datasource.url = jdbc:mysql://localhost:1204/test
spring.datasource.username = root
spring.datasource.password = 1204
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Cette erreur apparaîtra au démarrage, aidez-moi à la résoudre
Veuillez demander à un grand patron de résoudre le problème à distance... cela a pris un demi-mois et je n'ai pas terminé le QAQ
Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'
Action:
Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.
Maintenant, c'est la question : dois-je configurer les beans dans le fichier XML ? Il semble qu'il n'y ait pas de tutoriels. J'ai téléchargé jpa sur le marché mais cela ne fonctionne pas. J'ai toujours eu ce problème. Après avoir lu les tutoriels en ligne, il semble que personne n'ait ce problème... S'il vous plaît, QAQ à distance
.
Dépendez-vous du pilote JDBC de MySQL dans pom.xml ?
Il y a toujours un problème avec le package externe, vérifiez org.springframework.jdbc
Je n'ai pas vu votre configuration spécifique, donc je ne peux que deviner :
Avez-vous exclu la source de données par défaut de Springboot au lieu d'implémenter une source de données personnalisée ?
Essayez de supprimer include = {DataSourceAutoConfiguration.class} dans @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}), ou remplacez-le par une source de données telle que druid ou dbcp.
N'avez-vous pas ajouté de dépendance MySQL ?
Je vous enverrai la configuration que j'utilise récemment pour votre référence :
Je vous enverrai la configuration nécessaire et omettre les autres
Configuration 1.pom.xml :
2.configuration de l'application.properties
Re-téléchargez jpa et changez la source. J'ai déjà rencontré ce problème
.