Springboot web项目 部署到tomcat 为什么会启动两次?

wjybokee 2016-11-30 10:42:47


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

[2016-11-30 10/:37/:46]DEBUG org.jboss.logging(line/:19) -Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2016-11-30 10/:37/:46]INFO org.hibernate.validator.internal.util.Version(line/:30) -HV000001: Hibernate Validator 5.2.4.Final
[2016-11-30 10/:37/:46]INFO com.zhengyang.HgdcmsApplication(line/:48) -Starting HgdcmsApplication v0.0.1-SNAPSHOT on ZF-WJY with PID 41740 (E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes started by Administrator in E:\java_ide\eclipse)
[2016-11-30 10/:37/:46]DEBUG com.zhengyang.HgdcmsApplication(line/:51) -Running with Spring Boot v1.4.2.RELEASE, Spring v4.3.4.RELEASE
[2016-11-30 10/:37/:46]INFO com.zhengyang.HgdcmsApplication(line/:661) -No active profile set, falling back to default profiles: default
[2016-11-30 10/:37/:46]DEBUG org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver(line/:70) -Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\AdminDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\ChargeDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\LogDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\NoticeDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\PrisonerDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\UserDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\UserInfoDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\UserRoleDao.class]
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'adminDao' and 'com.zhengyang.dao.AdminDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'adminDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'chargeDao' and 'com.zhengyang.dao.ChargeDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'chargeDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'logDao' and 'com.zhengyang.dao.LogDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'logDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'noticeDao' and 'com.zhengyang.dao.NoticeDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'noticeDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'prisonerDao' and 'com.zhengyang.dao.PrisonerDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'prisonerDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'userDao' and 'com.zhengyang.dao.UserDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'userDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'userInfoDao' and 'com.zhengyang.dao.UserInfoDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'userInfoDao'.
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:181) -Creating MapperFactoryBean with name 'userRoleDao' and 'com.zhengyang.dao.UserRoleDao' mapperInterface
[2016-11-30 10/:37/:51]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:217) -Enabling autowire by type for MapperFactoryBean with name 'userRoleDao'.
十一月 30, 2016 10:37:55 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring embedded WebApplicationContext
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver(line/:70) -Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.engine.ConfigurationImpl(line/:156) -Setting custom MessageInterpolator of type org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.engine.ConfigurationImpl(line/:178) -Setting custom ConstraintValidatorFactory of type org.springframework.validation.beanvalidation.SpringConstraintValidatorFactory
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.engine.ConfigurationImpl(line/:192) -Setting custom ParameterNameProvider of type com.sun.proxy.$Proxy56
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser(line/:91) -Trying to load META-INF/validation.xml for XML based Validator configuration.
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper(line/:47) -Trying to load META-INF/validation.xml via user class loader
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper(line/:54) -Trying to load META-INF/validation.xml via TCCL
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper(line/:60) -Trying to load META-INF/validation.xml via Hibernate Validator's class loader
[2016-11-30 10/:37/:55]DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser(line/:98) -No META-INF/validation.xml found. Using annotation based configuration only.
[2016-11-30 10/:38/:01]DEBUG org.apache.ibatis.logging.LogFactory(line/:135) -Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.

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

[2016-11-30 10/:38/:17]DEBUG org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver(line/:70) -Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
[2016-11-30 10/:38/:17]INFO com.zhengyang.ServletInitializer(line/:661) -No active profile set, falling back to default profiles: default
[2016-11-30 10/:38/:19]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\AdminDao.class]
[2016-11-30 10/:38/:19]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\ChargeDao.class]
[2016-11-30 10/:38/:19]DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner(line/:286) -Identified candidate component class: file [E:\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hgdcms\WEB-INF\classes\com\zhengyang\dao\LogDao.class]
...全文
4077 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
litc028 2018-04-27
  • 打赏
  • 举报
回复
最近我也遇到这个问题,经过多次尝试后已经解决,方法如下: 如果只有一个项目,那么用楼上兄弟的方法可行,但是如果有两上或者以上项目,则需要这样修改: 项目名称: projectA,projectB,A需要在根目录访问 容器目录: /opt/tomcat/ 将projectA放到/opt/tomcat/projectA,将projectB放到默认目录/opt/tomcat/webapps 接着更改server.xml,在host处设置如下: <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" reloadable="false" docBase="/opt/tomcat/projectA"/> 原理:因为projectA不在webapps目录下,所以只会加载一次而不会重复加载。
瓦史托德 2017-12-15
  • 打赏
  • 举报
回复
<Host name="localhost" appBase=""> <Context docBase="D:\apache-tomcat-8.5.14\webapps\web" /> </Host> Host的appBase去掉 context的docBase补全
青年卫大师 2017-09-28
  • 打赏
  • 举报
回复
降自带的tomcat禁用了
deng_xintao 2017-09-28
  • 打赏
  • 举报
回复
找到解决办法了。在不修改之前现成的项目基础上,只加载一次的方式是: package com.pa.openapi.netway.front; import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.web.WebApplicationInitializer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @EnableWebMvc @SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class,JpaRepositoriesAutoConfiguration.class}) @EnableDiscoveryClient @EnableFeignClients public class Application implements WebApplicationInitializer { public static void main(String[] args) { System.out.println("*********************Application***************************************"); SpringApplication.run(Application.class, args); } // @Override // protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // return builder.sources(this.getClass()); // } @Override public void onStartup(ServletContext servletContext) throws ServletException { // TODO Auto-generated method stub } } package com.pa.openapi.netway.front; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySources; @Configuration @PropertySources({@PropertySource("classpath:application.properties"),@PropertySource("classpath:bootstrap.properties")}) public class ConfigurationClass { } 这样子就能解决。只加载一次
deng_xintao 2017-09-27
  • 打赏
  • 举报
回复
请问如何解决的?我也遇到了这个问题
gchm 2017-09-26
  • 打赏
  • 举报
回复
我也有这个问题,请问楼主解决了么
R.I.P24 2017-09-13
  • 打赏
  • 举报
回复
我也有这个问题,请问楼主解决了么
whataboutnow-NEU 2017-07-17
  • 打赏
  • 举报
回复
请问,这个问题解决了吗?
wjybokee 2016-11-30
  • 打赏
  • 举报
回复
springboot web 应用 使用自带tomcat 启动正常,部署到外部tomcat 上 启动的时候加载两次。
月明星稀灬 2016-11-30
  • 打赏
  • 举报
回复
是不是tomcat的 webapps目录下有一个项目,然后你给他又另外配了一个项目路径。 建议清一下tomcat缓存,IDE编译缓存。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧