Java Spring引导不会在Tomcat实例中启动
我有一个只包含一些预定任务的小型web应用程序。当我在Tomcat实例上部署这个应用程序时,什么都没有发生。没有生成日志,调度不起作用。我找到的应用程序的唯一日志是:Java Spring引导不会在Tomcat实例中启动,java,spring-boot,tomcat8,Java,Spring Boot,Tomcat8,我有一个只包含一些预定任务的小型web应用程序。当我在Tomcat实例上部署这个应用程序时,什么都没有发生。没有生成日志,调度不起作用。我找到的应用程序的唯一日志是: 31-Aug-2018 11:05:06.120 INFO [http-nio-80-exec-107] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath 我对应用程序
31-Aug-2018 11:05:06.120 INFO [http-nio-80-exec-107] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
我对应用程序类有以下注释(main位于其中):
计划任务所在的类如下所示:
@Component
public class MQMonitorTask {
private Logger logger = LoggerFactory.getLogger(MQMonitorTask.class);
/**
* Get the MQ depth of all the queues and send it to Influx
*/
@Scheduled(fixedDelay = 10000)
public void getMQData() {
logger.info("test");
//Custom code here
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlascopco</groupId>
<artifactId>PTITMonitorIntegrator</artifactId>
<version>1.0.0</version>
<name>PTITMonitorIntegrator</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq.allclient</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>msg.client.commonservices.wmq</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.influxdb/influxdb-java -->
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<packaging>war</packaging>
<description>Spring boot application that will query for information for PT-IT Monitor system</description>
</project>
Pom文件看起来像:
@Component
public class MQMonitorTask {
private Logger logger = LoggerFactory.getLogger(MQMonitorTask.class);
/**
* Get the MQ depth of all the queues and send it to Influx
*/
@Scheduled(fixedDelay = 10000)
public void getMQData() {
logger.info("test");
//Custom code here
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlascopco</groupId>
<artifactId>PTITMonitorIntegrator</artifactId>
<version>1.0.0</version>
<name>PTITMonitorIntegrator</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq.allclient</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>msg.client.commonservices.wmq</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.influxdb/influxdb-java -->
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<packaging>war</packaging>
<description>Spring boot application that will query for information for PT-IT Monitor system</description>
</project>
4.0.0
com.atlascopco
光电监测器
1.0.0
光电监测器
org.springframework.boot
spring启动程序父级
2.0.4.1发布
UTF-8
UTF-8
1.8
com.ibm
mq
1
com.ibm
mq.allclient
1
org.springframework.boot
弹簧靴
2.0.4.1发布
org.springframework.boot
弹簧靴开发工具
真的
com.ibm
msg.client.commonservices.wmq
1
org.springframework.boot
spring引导配置处理器
真的
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧靴开发工具
运行时
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
弹簧启动机tomcat
假如
com.fasterxml.jackson.core
杰克逊数据绑定
2.9.6
org.xdb
xdbjava
2.12
org.springframework.boot
springbootmaven插件
战争
用于查询PT-IT监控系统信息的Spring引导应用程序
有人能帮我找到这个问题吗?当我创建一个
jar
文件而不是war
文件,并使用java-jar file.jar
运行它时,它只需启动,就可以正常工作。但是需要在Tomcat服务器上运行。您看过这个spring引导文档了吗
您的应用程序类是否扩展了SpringBootServletilizer?尝试更改
jar
到
war在pom.xml中正如我所见,您没有使用
spring boot maven插件
就像这里我不使用的那样';我不认为应该提供spring boot starter tomcat
。