Springboot部署到tomcat中启动了两次问题

一、现象

启动时候出现如下2次:

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

如果使用了jta的atomikos事务会出现tmlog已被占用问题。

二、处理

2.1 去除springboot内置tomcat

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <groupId>org.springframework.boot</groupId>
            </exclusion>
        </exclusions>
    </dependency>

2.2

tomcat的server.xml配置有问题

如果<Context>节点里配置了应用全路径,那么<host>节点里的appBase要置空,否则就是这出问题,host和context分别加载一次

<Host name=“localhost” appBase="" unpackWARs=“true” autoDeploy=“true”>

重启tomcat即可

原文地址:https://www.cnblogs.com/51ma/p/15102081.html