Tag Archives: Springboot startup error

[Solved] SpringBoot Startup Error: org.springframework.beans.factory.UnsatisfiedDependencyException Error creating

Full Error:

WARN 7612 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘processBusinessController’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [F:code ariacs5g ariacs5g_src ariacs5g-parent ariacs5g-power-parent2 ariacs5g-host-service2 argetclassescom ariacshostmapperUserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory
2020-12-25 21:55:07.728 INFO 7612 — [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-12-25 21:55:07.737 INFO 7612 — [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-12-25 21:55:07.757 ERROR 7612 — [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘processBusinessController’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [F:code ariacs5g ariacs5g_src ariacs5g-parent ariacs5g-power-parent2 ariacs5g-host-service2 argetclassescom ariacshostmapperUserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorKaTeX parse error: Undefined control sequence: \[ at position 78: …sor.java:598) ~\̲[̲spring-beans-5.…doGetBeanKaTeX parse error: Undefined control sequence: \[ at position 34: …ory.java:321) ~\̲[̲spring-beans-5.…doGetBeanKaTeX parse error: Undefined control sequence: \[ at position 34: …ory.java:321) ~\̲[̲spring-beans-5.…AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:595) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
… 19 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [F:code ariacs5g ariacs5g_src ariacs5g-parent ariacs5g-power-parent2 ariacs5g-host-service2 argetclassescom ariacshostmapperUserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1506) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1386) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBeanKaTeX parse error: Undefined control sequence: \[ at position 34: …ory.java:321) ~\̲[̲spring-beans-5.…ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:637) ~[spring-context-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadataKaTeX parse error: Undefined control sequence: \[ at position 53: …ata.java:180) ~\̲[̲spring-beans-5.…doGetBeanKaTeX parse error: Undefined control sequence: \[ at position 34: …ory.java:321) ~\̲[̲spring-beans-5.…E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIBEnhancerBySpringCGLIB602 d 46 a 8. C G L I B 602d46a8.CGLIB602d46a8.CGLIBsqlSessionFactoryKaTeX parse error: Undefined control sequence: \[ at position 17: …(<generated>) ~\̲[̲mybatis-plus-bo…E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIBEnhancerBySpringCGLIB602 d 46 a 8 602d46a8602d46a8F a s t C l a s s B y S p r i n g C G L I B FastClassBySpringCGLIBFastClassBySpringCGLIBKaTeX parse error: Undefined control sequence: \[ at position 31: …(<generated>) ~\̲[̲mybatis-plus-bo…BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.18.RELEASE.jar:5.1.18.RELEASE]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration
E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
602d46a8.sqlSessionFactory() ~[mybatis-plus-boot-starter-3.4.1.jar:3.4.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.18.RELEASE.jar:5.1.18.RELEASE]
… 58 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.mybatis.logging.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152]
… 70 common frames omitted

Solution: The introduction of both Mybatis and Mybatis-plus into the dependency will cause a conflict, either one. In addition to noticing if there is a conflict in the pom file of this module, we also need to see if the parent module of this module has already introduced the mybaits dependency and you later introduce the Mybatis-plus module in this module, causing a conflict. This scenario is more insidious and not easy to detect.

[Solved] Springboot Package jar and Startup Error: It was loaded from the following location

Previously, when using springboot to develop the system, the @Resouse annotation was used. There was no exception during the idea runtime, but the jar package conflict was reported when the deployment was packaged.

09:07:51.234 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.<init>(CommonAnnotationBeanPostProcessor.java:664)

The following method did not exist:

    'java.lang.String javax.annotation.Resource.lookup()'

The method's class, javax.annotation.Resource, is available from the following locations:

    jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/javax/annotation/Resource.class
    jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar!/javax/annotation/Resource.class

The class hierarchy was loaded from the following locations:

    javax.annotation.Resource: jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.annotation.Resource

Reason:

jsr250-api-1.0.jar and jakarta.annotation-api-1.3.5.jar are duplicated

Solution:

Import the following dependency in the pom of Maven. the codes is as below:

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

The purpose of this is to make the system automatically import the latest jar package

[Solved] SpringBoot Startup Error: Description:Web server failed to start. Port 9090 was already in use.(win10)

1. Error reporting picture:

2. Win + R, enter CMD, find the port,

Invalid instruction

Valid instruction

3. End the process of occupying the port. The occupied process here is 25588

(1) open the Task Manager and click the details option

(2) Find Java.exe with PID 25588 in the name of java.exe

(3) Right click to end the task -> End process

4. Start springboot again to see if it is resolved.

Successfully started, solved.

SpringBoot Startup Error: Failed to start component [Connector[HTTP/1.1-8080]]

Failed to start component [Connector[HTTP/1.1-8080]]

The following error is reported when starting springboot:

Failed to start component [Connector[HTTP/1.1-8080

protocol handler start failed

Solution:
It is the port number occupation problem:
just close the occupied 8080 port number, enter in cmd: netstat -aon|findstr “port number”, find the PID corresponding to 8080 (port number), and then open the task manager. Find the corresponding PID in “Details” and stop the task.

Springboot startup error: Field elasticsearchRestTemplate in cn.lili.modules.material.serviceImpl.QrMaterialServiceImpl required a bean of type

 

Description:

Field elasticsearchRestTemplate in cn.lili.modules.material.serviceImpl.QrMaterialServiceImpl required a bean of type ‘org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate’ in your configuration.
Process finished with exit code 1

Solution:

Add lazy loading annotation: @Lazy

[Solved] SpringBoot Startup Error: Unable to start LiveReload server

WARN 12000 — [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server

Article catalog

Cause of problem: solution:

problem

0000-00-00 00:00:55.497  WARN 12000 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : Unable to start LiveReload server

reason:

When you use the springboot hot deployment plug-in devtools , and start multiple applications at the same time, the console will report this warning;

The problem is that a port is configured in devtoolsproperties. The default is 35729

       public static class Livereload {
                private boolean enabled = true;

                private int port = 35729;

        ... }

Multiple ports are in conflict, causing the hot deployment plug-in behind to not take effect.


Solution:

Add the following configuration to the application.properties file:

spring. Devtools. Livereload. Port = 35731 (specified port does not duplicate port)

Springboot startup error “No bean named’org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry’ available”

1. Problem

springboot startup error

"D:\Program Files\Java\jdk-11\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx. enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\lib\idea_rt.jar=59473:D:\Program Files \JetBrains\IntelliJ IDEA 2019.1.2\bin" -Dfile.encoding=UTF-8 -classpath D:\workroomMy\demoSpring\out\production\classes;D:\workroomMy\demoSpring\out\production\resources;C:\ Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.3.0.RELEASE\459a5d406c56770d9616c5b272bae9fbc777a994\spring-boot-starter-web-2.3.0 .RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.mybatis.spring.boot\mybatis-spring-boot-starter\2.1.2\724ae339bf7d1087612c7186133ed9701f103ddd\mybatis-spring-boot-starter-2.1.2.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter- json\2.3.0.RELEASE\dfdd3336ee920e4bc75f4ed726c3894c7821c31b\spring-boot-starter-json-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework. boot\spring-boot-starter-jdbc\2.3.0.RELEASE\ddc9ee3da589998143de4cada9d5e3aa1dc39f83\spring-boot-starter-jdbc-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\ files-2.1\org.springframework.boot\spring-boot-starter\2.3.0.RELEASE\7b65ef478cf4d21ec70432e11055c2c83371b305\spring-boot-starter-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\ modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.3.0.RELEASE\a8038c9ce2beb7bd3c1980ecadd79f65f36d9311\spring-boot-starter-tomcat-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.mybatis.spring.boot\mybatis-spring-boot-autoconfigure\2.1.2\f322930f6a0d07c78481853e6625ffb779bcdeb7\mybatis-spring- boot-autoconfigure-2.1.2.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.3.0.RELEASE\63e909ec18045377f5bcbedbf29f54691dc54ba0\ spring-boot-autoconfigure-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.3.0.RELEASE\ 52fabd810811f5352ebf6a0a7049550f7d4ec1b9\spring-boot-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.3. 0.RELEASE\fe2b3809c5763dd7fe02ab174ebe5ee9ed708fbe\spring-boot-starter-logging-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.2.6.RELEASE\fc54ea95c4c96cd0ab5272319905d4da5d632383\spring-webmvc-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework. boot\spring-boot-devtools\2.3.0.RELEASE\e13dced857910467ff468bba0656a3857deda524\spring-boot-devtools-2.3.0.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\ org.springframework\spring-web\5.2.6.RELEASE\8cc2dbd266eb8f02d2df0895c8e887269e8aed88\spring-web-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org. mybatis\mybatis\3.5.4\83853443357d61258d2634758079f355a0db69ee\mybatis-3.5.4.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.mybatis\mybatis-spring\2.0.4\ 3771548c4d9f78789be33bed01f42d6592757fe1\mybatis-spring-2.0.4.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.11.0\168b2d0e11478b9f0a1bfccd62d6b5e8547b1e6f\jackson-datatype-jsr310-2.11.0.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml. jackson.core\jackson-annotations\2.11.0\c626020ae55d19c690d25cb51c1532ba76e5890f\jackson-annotations-2.11.0.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson. datatype\jackson-datatype-jdk8\2.11.0\cca91d6375258fd7ff2a6abb7bf91eef492bd606\jackson-datatype-jdk8-2.11.0.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml. jackson.module\jackson-module-parameter-names\2.11.0\950a1e9a7c1093e7ffd92b216d5a0667f1e39058\jackson-module-parameter-names-2.11.0.jar;C:\Users\admin\.gradle\caches\modules-2\files- 2.1\com.fasterxml.jackson.core\jackson-core\2.11.0\f84302e14648f9f63c0c73951054aeb2ff0b810a\jackson-core-2.11.0.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.11.0\8f5aaf3878b0647ff3a16610af53b1a5c05d9f15\jackson-databind-2.11.0.jar;C:\Users\admin\.gradle\ caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.13.2\7e2845170ed4fdeb87f1fdc9131b743c61645da3\log4j-to-slf4j-2.13.2.jar;C:\Users\admin\. gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.13.2\567ea514dedd8679c429c5b5b39b0d67b6464c3c\log4j-api-2.13.2.jar;C:\Users\admin\.gradle\ caches\modules-2\files-2.1\org.springframework\spring-context\5.2.6.RELEASE\f8f4420f268b054db12bf0dc7128adc09ab39a7\spring-context-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\ modules-2\files-2.1\org.springframework\spring-aop\5.2.6.RELEASE\84fffb7cad5816763683a3f251f942aa9f667a7e\spring-aop-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules- 2\files-2.1\org.springframework\spring-jdbc\5.2.6.RELEASE\43747a50376e662c2d889ce7b3cd5b9204962ff3\spring-jdbc-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\ org.springframework\spring-tx\5.2.6.RELEASE\965726c96c42025eedeec047c2afad884203145a\spring-tx-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org. springframework\spring-beans\5.2.6.RELEASE\d1b4c338e52dac001a48e29a605bb8f73572ad84\spring-beans-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework\ spring-expression\5.2.6.RELEASE\ae0bc9fdf6cf08d885b9aee26c21efa24245d46c\spring-expression-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework\spring- core\5.2.6.RELEASE\5533695a01f5a1163428932abf6c5ba70e837a2d\spring-core-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.2.6.RELEASE\47b092c5c7a97ad330ae29d84d64e42c63a11b7a\spring-jcl-5.2.6.RELEASE.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.glassfish\ jakarta.el\3.0.3\dab46ee1ee23f7197c13d7c40fce14817c9017df\jakarta.el-3.0.3.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\3.4.5\ aa1a2c00aae8e4ba8308e19940711bb9525b103d\HikariCP-3.4.5.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84eecd0d6163332ffkarta065f616\jakarta. api-1.3.5.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2. 3.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar; C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.30\d58bebff8cbf70ff52b59208586095f467656c30\jul-to-slf4j-1.7.30.jar; C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.30\b5a4b6d16ab13e34a88fae84c35cd5d68cac922c\slf4j-api-1.7.30.jar;C:\Users\admin \.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.26\a78a8747147d2c5807683e76ec2b633e95c14fe9\snakeyaml-1.26.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\ org.projectlombok\lombok\1.18.12\48e4e5d60309ebd833bc528dcf77668eab3cd72c\lombok-1.18.12.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat- embed-websocket\9.0.35\62ab2d7d7d029ea728ea8f8d3151ba93882b52ca\tomcat-embed-websocket-9.0.35.jar;C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\ tomcat-embed-core\9.0.35\8a99064fce4b152a7dc9bea1798ba828a2cecf0f\tomcat-embed-core-9.0.35.jar com.example.demo.DemoApplication

  . ____ _ __ _ _
 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
(()\___ |'_ |'_| |'_ \/ _` | \ \ \ \
 \\/ ___)| |_)| | | | | || (_| |))))
  '|____| .__|_| |_|_| |_\__, | / / / /
 ==========|_|==============|___/=/_/_/_/
 :: Spring Boot :: (v2.3.0.RELEASE)

2020-05-29 09:42:41.536 INFO 6888 --- [restartedMain] com.example.demo.DemoApplication: Starting DemoApplication on A01 with PID 6888 (D:\workroomMy\demoSpring\out\production\classes started by admin in D:\workroomMy\demoSpring)
2020-05-29 09:42:41.540 INFO 6888 --- [restartedMain] com.example.demo.DemoApplication: No active profile set, falling back to default profiles: default
2020-05-29 09:42:41.592 INFO 6888 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor: Devtools property defaults active! Set'spring.devtools.add-properties' to'false' to disable
2020-05-29 09:42:41.593 INFO 6888 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor: For additional web related logging consider setting the'logging.level.web' property to'DEBUG'
2020-05-29 09:42:42.120 WARN 6888 --- [restartedMain] omsmapper.ClassPathMapperScanner: No MyBatis mapper was found in'[com.example.demo]' package. Please check your configuration.
2020-05-29 09:42:42.453 INFO 6888 --- [restartedMain] osbwembedded.tomcat.TomcatWebServer: Tomcat initialized with port(s): 8080 (http)
2020-05-29 09:42:42.461 INFO 6888 --- [restartedMain] o.apache.catalina.core.StandardService: Starting service [Tomcat]
2020-05-29 09:42:42.461 INFO 6888 --- [restartedMain] org.apache.catalina.core.StandardEngine: Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-05-29 09:42:42.529 INFO 6888 --- [restartedMain] oaccC[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext
2020-05-29 09:42:42.529 INFO 6888 --- [restartedMain] osweb.context.ContextLoader: Root WebApplicationContext: initialization completed in 936 ms
2020-05-29 09:42:42.665 INFO 6888 --- [restartedMain] ossconcurrent.ThreadPoolTaskExecutor: Initializing ExecutorService'applicationTaskExecutor'
2020-05-29 09:42:42.753 WARN 6888 --- [restartedMain] ConfigServletWebServerApplicationContext: Exception encountered during context initialization-cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource ]: Factory method'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2020-05-29 09:42:42.753 INFO 6888 --- [restartedMain] ossconcurrent.ThreadPoolTaskExecutor: Shutting down ExecutorService'applicationTaskExecutor'
2020-05-29 09:42:42.755 INFO 6888 --- [restartedMain] o.apache.catalina.core.StandardService: Stopping service [Tomcat]
2020-05-29 09:42:42.766 INFO 6888 --- [restartedMain] ConditionEvaluationReportLoggingListener: 

Error starting ApplicationContext. To display the conditions report re-run your application with'debug' enabled.
2020-05-29 09:42:42.769 ERROR 6888 --- [restartedMain] osbdLoggingFailureAnalysisReporter: 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource:'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

2020-05-29 09:42:42.780 WARN 6888 --- [restartedMain] osboot.SpringApplication: Unable to close ApplicationContext

org.springframework.beans.factory.BeanCreationException: Error creating bean with name'org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:409) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:245) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:197) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:134) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.boot.availability.AvailabilityChangeEvent.publish(AvailabilityChangeEvent.java:81) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.availability.AvailabilityChangeEvent.publish(AvailabilityChangeEvent.java:67) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:167) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:978) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:814) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at com.example.demo.DemoApplication.main(DemoApplication.java:12) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.0.RELEASE.jar:2.3.0.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:409) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:94) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:76) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:347) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    ... 33 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:814) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1282) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor.postProcessBeforeInitialization(ConfigurationClassPostProcessor.java:456) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    ... 56 common frames omitted


Process finished with exit code 0

 

2. Solution

Authentication see error prompt

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

 

The error may be due to the lack of configuration database related information. If the project does not need to configure the database, you can add it to the startup class:

(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})

 

 perfect!

[Solved] Springboot Startup Error: Consider defining a bean of type ‘XXX’ in your configuration.

I. Introduction:

The project was built using springboot automatic injection, but an error was reported when it started! ! ! , The error is as shown below:

Description: Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of

 type'com.xxx.xxx.dao.UserEntityMapper' that could not be found.
 
Action: Consider defining a bean of

 type'com.xxx.xxx .dao.UserEntityMapper' in your configuration.

2. Solution:

1. Check whether the annotations you wrote are wrong, and not.

2. Find solutions on the Internet: as follows:

step one:

  Add in the configuration file of springboot, the configuration of mybatis is as follows:

mybatis: 
  typeAliasesPackage: com.xxx.xxx.dao.entity 
  mapperLocations: classpath:mapper/*.xml

 Step two:

  ① Put the interface and the corresponding implementation class in the same directory or its subdirectory as the application startup class , so that the annotations can be scanned, which is the most trouble-free way. (Not tested)
  ② Or add @MapperScan or @ComponentScan annotations to the startup class , and manually specify the annotations under which packages the application class should scan, as shown below: 

@SpringBootApplication
 @ComponentScan(basePackages = {"com.xxx.xxx.dao"})

③Or add @Mapper annotation   on the interface .

@Mapper
 public  interface UserMapper { 
}

ps: The reason why the corresponding Bean was not found is because @SpringBootApplication did not scan it.

SpringBoot startup error Failed to determine a suitable driver class

Add a simple controller to a new SpringBoot project from SpringBoot Initializer , and the startup error is as follows:

  . ____ _ __ _ _
 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
(()\___ |'_ |'_| |'_ \/ _` | \ \ \ \
 \\/ ___)| |_)| | | | | || (_| |))))
  '|____| .__|_| |_|_| |_\__, | / / / /
 ==========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-09 10:37:16.750  INFO 11232 --- [           main] com.dongdong.demo.DemoApplication        : Starting DemoApplication on PC-20170304VFOZ with PID 11232 (E:\Spring\Projects\demo\target\classes started by Administrator in E:\Spring\Projects\demo)
2019-09-09 10:37:16.752  INFO 11232 --- [           main] com.dongdong.demo.DemoApplication        : No active profile set, falling back to default profiles: default
2019-09-09 10:37:17.711  INFO 11232 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-09 10:37:17.730  INFO 11232 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces.
2019-09-09 10:37:18.023  INFO 11232 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3d0e1f1a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-09 10:37:18.327  INFO 11232 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-09-09 10:37:18.359  INFO 11232 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-09-09 10:37:18.360  INFO 11232 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-09 10:37:18.476  INFO 11232 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-09-09 10:37:18.476  INFO 11232 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1645 ms
2019-09-09 10:37:18.732  INFO 11232 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-09 10:37:18.842  WARN 11232 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2019-09-09 10:37:18.843  INFO 11232 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2019-09-09 10:37:18.846  INFO 11232 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-09-09 10:37:18.860  INFO 11232 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-09 10:37:18.864 ERROR 11232 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Process finished with exit code 1

 

the reason

The application does not use DataSource, but introduces mybatis-spring-boot-starter in pom.xml

 

Problem solution

There are two types:
remove the dependency of mybatis-spring-boot-starter, so that it will not trigger the spring boot related
code    disable the spring boot automatically initialize the DataSource related code

There are two ways to prohibit:

In the @SpringBootApplication of the startup class, add

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class })

 

Configure in application.properties:

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration

 

Get it done!

An error is reported when springboot starts: error creating bean with name ‘XXXX’

Error creating bean with name ‘XXXX’

The complete errors are as follows: Cause Analysis:

The complete error report is as follows:

 Exception encountered during context initialization - cancelling refresh attempt: 
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 
 'testHelloController': Unsatisfied dependency expressed through field 'testHelloService'; nested exception is 
 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 
 'com.jun.service.test.TestHelloService' available: expected at least 1 bean which qualifies as autowire 
 candidate. Dependency annotations: 
 {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Cause analysis:

Because I’m a beginner of springboot, I just want to let the project run first to see the effect. If it takes half a day to build the project structure completely, I will report such a mistake as soon as I start it. The reason is very clear, that is, I can’t find the testhelloservice object template to inject it when I start it, and then I look at the @ service annotation in the service layer. It’s very smart When spring boot is started, it does not scan the service layer. After looking at the data, if so, you can directly type a annotation @ componentscan in the application of spring boot startup class to solve this problem:
the following is the code before error reporting:

package com.jun.web.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

Code after error reporting:

package com.jun.web.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

**@ComponentScan(basePackages = {"com.jun.core.*","com.jun.service.*","com.jun.web.*"})**
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}