在jetty容器下部署失敗,希望得到老師或者大家的幫助
老師,我寫了一個(gè)簡單示例程序,打包成war,部署在jetty(jetty 9.x)容器下一直不能啟動項(xiàng)目,不知道什么原因,也沒有錯(cuò)誤日志打印,訪問的時(shí)候返回404,但是部署在Tomcat容器或者使用java -jar 命令是可以成功啟動的,其中spring boot啟動類代碼如下:
import?org.springframework.boot.SpringApplication; import?org.springframework.boot.autoconfigure.SpringBootApplication; import?org.springframework.boot.builder.SpringApplicationBuilder; import?org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication public?class?Application?extends?SpringBootServletInitializer?{ ???@Override ???protected?SpringApplicationBuilder?configure(SpringApplicationBuilder?application)?{ ??????return?application.sources(Application.class); ???} ???public?static?void?main(String[]?args)?{ ??????SpringApplication.run(Application.class,?args); ???} }
pom.xml 文件主要配置如下:
<?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.example</groupId> ???<artifactId>demo</artifactId> ???<version>0.1.0-SNAPSHOT</version> ???<packaging>war</packaging> ???<name>springboot-security-jwt</name> ???<description>Demo?project?for?Spring?Boot</description> ???<parent> ??????<groupId>org.springframework.boot</groupId> ??????<artifactId>spring-boot-starter-parent</artifactId> ??????<version>1.5.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>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-web</artifactId> ?????????<exclusions> ????????????<exclusion> ???????????????<groupId>org.springframework.boot</groupId> ???????????????<artifactId>spring-boot-starter-tomcat</artifactId> ????????????</exclusion> ?????????</exclusions> ??????</dependency> ??????<dependency> ?????????<groupId>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-jetty</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-security</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-data-jpa</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-mobile</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>mysql</groupId> ?????????<artifactId>mysql-connector-java</artifactId> ??????</dependency> ??????<dependency> ????????????<groupId>io.jsonwebtoken</groupId> ????????????<artifactId>jjwt</artifactId> ????????????<version>0.6.0</version> ????????</dependency> ??????<dependency> ?????????<groupId>joda-time</groupId> ?????????<artifactId>joda-time</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>com.fasterxml.jackson.core</groupId> ?????????<artifactId>jackson-databind</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>com.fasterxml.jackson.core</groupId> ?????????<artifactId>jackson-annotations</artifactId> ??????</dependency> ??????<dependency> ?????????<groupId>com.h2database</groupId> ?????????<artifactId>h2</artifactId> ?????????<scope>runtime</scope> ??????</dependency> ????????<dependency> ????????????<groupId>org.springframework.boot</groupId> ????????????<artifactId>spring-boot-devtools</artifactId> ????????????<optional>true</optional> ????????</dependency> ????????<dependency> ??????????<groupId>org.webjars</groupId> ??????????<artifactId>angularjs</artifactId> ??????????<version>1.5.8</version> ????????</dependency> ????????<dependency> ????????????<groupId>org.webjars.bower</groupId> ????????????<artifactId>angular-route</artifactId> ????????????<version>1.5.9</version> ????????</dependency> ????????<dependency> ??????????<groupId>org.webjars</groupId> ??????????<artifactId>bootstrap</artifactId> ??????????<version>3.3.7</version> ????????</dependency> ??????<dependency> ????????????<groupId>org.webjars</groupId> ????????????<artifactId>jquery</artifactId> ????????????<version>2.1.1</version> ????????</dependency> ??????<dependency> ?????????<groupId>org.springframework.boot</groupId> ?????????<artifactId>spring-boot-starter-test</artifactId> ?????????<scope>test</scope> ??????</dependency> ??????<dependency> ?????????<groupId>org.springframework.security</groupId> ?????????<artifactId>spring-security-test</artifactId> ?????????<scope>test</scope> ??????</dependency> ???</dependencies> ???<repositories> ??????<repository> ?????????<id>nexus-aliyun</id> ?????????<name>Nexus?aliyun</name> ?????????<url>http://maven.aliyun.com/nexus/content/groups/public</url> ??????</repository> ???</repositories> ???<build> ??????<finalName>${project.artifactId}</finalName> ??????<plugins> ?????????<plugin> ????????????<groupId>org.springframework.boot</groupId> ????????????<artifactId>spring-boot-maven-plugin</artifactId> ?????????</plugin> ??????</plugins> ???</build> </project>
我重寫了代碼,問題均能重現(xiàn),初步懷疑是jetty容器的原因,希望能得到老師的解答,
2018-01-31
<
dependency
>
????<
groupId
>org.springframework.boot</
groupId
>
????
<
artifactId
>spring-boot-starter-jetty</
artifactId
>
????<scope>provided</scope>
</
dependency
>