java - Après avoir remplacé Spring Boot par War et l'avoir déployé sur Tomcat local, le projet n'est pas accessible
某草草
某草草 2017-05-17 09:58:46
0
2
822

1. J'ai suivi le didacticiel en ligne pour transformer le projet Spring Boot en war for packaging, puis je l'ai déployé sur le Tomcat7.0 local, j'ai démarré Tomcat et j'ai constaté que le projet n'était pas accessible lors de l'accès au projet.

Contenu du fichier 2.pom

<project xmlns="http://maven.apache.org/POM/4... http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.ming.wei.yue</groupId>
<artifactId>bargain</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
</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.ming.wei.yue.ApplicationStart</start-class>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <!-- 这个未来方便本机测试使用的tomcat -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

</projet>

3. Configuration de la classe de démarrage

package com.ming.wei.yue;
importer org.springframework.boot.SpringApplication;
importer org.springframework.boot.autoconfigure.SpringBootApplication;
importer org.springframework.boot.builder.SpringApplicationBuilder;
importer org.springframework. boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
classe publique ApplicationStart étend SpringBootServletInitializer{

public static void main(String[] args){
    SpringApplication.run(ApplicationStart.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(ApplicationStart.class);
}

}

4.classe de contrôleur

package com.ming.wei.yue.action;
importer org.springframework.web.bind.annotation.RequestMapping;
importer org.springframework.web.bind.annotation.ResponseBody;
importer org.springframework.web.bind. annotation.RestController;

@RestController
bonne affaire de classe publique {

@RequestMapping(value="/test")
@ResponseBody
public String test(){
    return "ECS1";
}

}
5. Informations sur le profil

6. Utilisez directement la commande maven install pour empaqueter sur Eclipse

Placez ce package war dans le répertoire webapps de Tomcat sur votre ordinateur local et renommez-le en demo.war


7. Démarrez Tomcat7

8. Testez l'accès, accédez au rapport d'erreurs

S'il vous plaît, dites-moi ce qui ne va pas ?

某草草
某草草

répondre à tous(2)
阿神

Le server.port configuré dans votre application.yml est configuré avec le numéro de port de Tomcat intégré au Spring Boot. Une fois emballé dans un package war et déployé sur un Tomcat indépendant, le server.port que vous avez configuré ne fonctionnera pas.

小葫芦

D'après votre journal de capture d'écran, vous pouvez voir que Tomcat a été démarré avec succès. Le port est 8080
http://127.0.0.1:8080/demo/test

.
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!