我想将一个简单的Spring Boot Rest应用程序部署到Wildfly 9.0.2服务器中。它似乎部署但无法访问任何服务。
我一直遵循各种指示,例如: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html
但似乎仍然不适合我。
这是我的pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>com.vodafone.er</groupId>
<artifactId>config-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>config-app</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>com.vodafone.er.configapp.ConfigAppApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.7</version>
</dependency>
</dependencies>
<!--<build>-->
<!--<plugins>-->
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--<configuration>-->
<!--<jvmArguments>-->
<!-- -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005-->
<!--</jvmArguments>-->
<!--</configuration>-->
<!--</plugin>-->
<!--</plugins>-->
<!--</build>-->
这是我的应用程序/控制器类:
@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class ConfigAppApplication extends
SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ConfigAppApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ConfigAppApplication.class);
}
}
@RestController
class ConfigController {
@RequestMapping("/hello")
public String hello() {
return "hello world";
}
}
我将它部署在$ JBOSS_HOME / standalone / deployments上,它告诉我它已部署。
15:51:12,008 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "config-app-0.0.1-SNAPSHOT.war" with deployment "config-app-0.0.1-SNAPSHOT.war"
我得到了标记文件:
config-app-0.0.1-SNAPSHOT.war.deployed
jmx控制台告诉我应用程序也已启用。 每当我尝试访问端点时,例如当我尝试访问根上下文时,我得到403禁止,但当我尝试访问其余资源时,例如localhost:8080 / config-app / hello我收到404错误。
任何想法我做错了什么?
由于
答案 0 :(得分:3)
Wildfly使用了servow容器。尝试在您的应用程序中添加对该功能的支持。
参考:73.13 Use Undertow instead of Tomcat
<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-undertow</artifactId>
</dependency>
答案 1 :(得分:0)
<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>