abdelmouheimen:
私は、サンプルの春ブートアプリケーションを持っています。これは、Tomcatサーバーで動作しますが、私は戦争を生成するとJBossサーバー(7.1.1)でそれを展開するとき、私は404エラーを持っています。
これは私のrestControllerの例です:
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@RequestMapping(value="/test")
public String sayHello() {
return "Hello 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 MainApp extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(MainApp.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MainApp.class);
}
}
私は、application.propertiesファイルを追加し、私はそれで、この行を追加しました:
server.contextPath = / *
私jbos-web.xmlがこのようなものです:
> <?xml version="1.0" encoding="UTF-8"?> <!-- this is really not
> needed... you can just build (or rename WAR file to)
> spring-boot-jboss.war
> --> <!DOCTYPE jboss-web> <jboss-web> <context-root>/test</context-root> </jboss-web>
そして最後に私のpom.xmlは以下の通りです:
<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.boraji.tutorial.springboot</groupId>
<artifactId>spring-boot-hello-world-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<java.version>1.7</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<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>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
:私はこのURLを使用してapplciation実行にhttp:// localhost:8080 /テスト/テストが、404エラーが返されました。
ご協力ありがとうございました。
セバスチャン:
私は、JBoss EAP 6.4 /春ブーツ1.5で同じ問題を抱えていたし、何それは、このプロパティを追加した固定しました
server.servlet-path=/*
この記事で説明したように:JBOSS EAP 6.1に春ブーツを展開します
これは、JBoss EAP 7.1かかわらでこのプロパティずに罰金を働きました。