spring boot maven package war to tomcat mybatis/springbootstarter 1.1.1 start error
See original GitHub issueI create project with spring boot 1.4.0 and mybatis/spring-boot-starter 1.1.1.
The demo project in https://github.com/walkwolf/testboot Any help thanks!
@Autowired problem
I find @Autowired SqlSessionFactory factory; then get mapper is no problem. Use @Autowired Mapper is error.
@Autowired
SqlSessionFactory factory;
CityMapper mapper = factory.openSession().getMapper(CityMapper.class);
In other words, Mapper not exist in spring context. I trace the problem ,then find MybatisAutoConfiguration
log.debug("Could not determine auto-configuration " + "package, automatic mapper scanning disabled.");
When package war file with maven pom,then copy tomcat webapp directory,start tomcat, I got error below
九月 09, 2016 12:16:06 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deployment of web application archive D:\apache-tomcat-7.0.59\webapps\testboot.war has finished in 7,918 ms
九月 09, 2016 12:16:06 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
九月 09, 2016 12:16:06 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 12:16:06 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 8052 ms
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol pause
信息: Pausing ProtocolHandler ["http-apr-80"]
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol pause
信息: Pausing ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 1:31:32 下午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service Catalina
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["http-apr-80"]
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["http-apr-80"]
九月 09, 2016 1:31:32 下午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.59
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Jan 28 2015 15:51:10 UTC
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.59.0
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 7
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.1
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Java\jre8
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_31-b13
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\apache-tomcat-7.0.59
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-7.0.59
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=D:\apache-tomcat-7.0.59\conf\logging.properties
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-7.0.59\endorsed
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-7.0.59
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-7.0.59
九月 09, 2016 1:31:57 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=D:\apache-tomcat-7.0.59\temp
九月 09, 2016 1:31:57 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.32 using APR version 1.5.1.
九月 09, 2016 1:31:57 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
九月 09, 2016 1:31:58 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1j 15 Oct 2014)
九月 09, 2016 1:31:58 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
九月 09, 2016 1:31:58 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 1:31:58 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1544 ms
九月 09, 2016 1:31:58 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
九月 09, 2016 1:31:58 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.59
九月 09, 2016 1:31:58 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deploying web application archive D:\apache-tomcat-7.0.59\webapps\testboot.war
九月 09, 2016 1:32:05 下午 org.apache.catalina.core.ContainerBase addChildInternal
严重: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/testboot]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ABCController': Unsatisfied dependency expressed through field 'cityMapper': No qualifying bean of type [testboot.service.CityMapper] found for dependency [testboot.service.CityMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [testboot.service.CityMapper] found for dependency [testboot.service.CityMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:150)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:130)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5513)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [testboot.service.CityMapper] found for dependency [testboot.service.CityMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1406)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1057)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566)
... 32 more
九月 09, 2016 1:32:05 下午 org.apache.catalina.startup.HostConfig deployWAR
严重: Error deploying web application archive D:\apache-tomcat-7.0.59\webapps\testboot.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/testboot]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
九月 09, 2016 1:32:05 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deployment of web application archive D:\apache-tomcat-7.0.59\webapps\testboot.war has finished in 6,607 ms
九月 09, 2016 1:32:05 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
九月 09, 2016 1:32:05 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
九月 09, 2016 1:32:05 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 6709 ms
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
maven build failing when generating war package for spring ...
Spring boot magically knows how to enable/disable embedded Tomcat. ... (Which I saw in my application when attempting to run a Maven Install)....
Read more >Spring Boot - Deploy WAR file to Tomcat - Mkyong.com
In Spring Boot, to create a WAR for deployment, we need 3 steps: Extends SpringBootServletInitializer; Marked the embedded servlet container as ...
Read more >mybatis-spring-boot-autoconfigure – Introduction
You application can now be run as a normal Spring Boot application. Advanced scanning. The MyBatis-Spring-Boot-Starter will search, by default, for mappers ...
Read more >Spring Boot - Executable war file structure - LogicBig
In this tutorial we are first going to create a traditional maven war file and deploy it to the tomcat server, then we...
Read more >project import error : IDEA-267781 - YouTrack - JetBrains
RELEASE org.springframework.boot spring-boot-starter-tomcat 2.1.3. ... activemq-run 5.15.8 org.apache.activemq activemq-runtime-config ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@walkwolf
If you use auto configure for
DataSource
andDataSourceTransactionManager
, please contain thespring-jdbc
jar as classpath.Please try this.
Thanks.
No. This behavior depends on a IDE or build plugin implementation.
For example )
mvn spring-boot:run
) run normallyProbably, Eclipse and Spring Boot maven plugin import the
spring-jdbc
jar viaspring-boot-starter-jdbc
.