war?

pcww981p  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(173)

我在jetty服务器上部署springboot war时遇到了问题。例如,我遵循了以下教程:https://www.vojtechruzicka.com/spring-boot-war/ . 我在jetty服务器上运行了它(下载自https://www.eclipse.org/jetty/download.html 从命令运行 java -jar start.jar -.war已被添加到webapps目录中),并且可以正常工作。我的问题是,当我在当前项目中向webapps添加.war时,它不起作用。我只看到这个:空的web应用程序
jetty服务器具有webapps目录中的autodeploy.wars:

DeploymentManager deployer = new DeploymentManager();
deployer.setContexts(contexts);
WebAppProvider webapp_provider = new WebAppProvider();
webapp_provider.setMonitoredDirName("webapps");
webapp_provider.setScanInterval(15);
webapp_provider.setExtractWars(true);
webapp_provider.setConfigurationManager(new PropertiesConfigurationManager());

springboot war 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>org.example</groupId>
<artifactId>usermanagement</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-juli</artifactId>
        <version>9.0.0.M17</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>webjars-locator</artifactId>
        <version>0.30</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-jsp</artifactId>
        <version>9.2.21.v20170120</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.35.v20201120</version>
            <configuration>
                <webApp>
                    <contextPath>/usermanagement</contextPath>
                </webApp>
                <scanIntervalSeconds>0</scanIntervalSeconds>
            </configuration>
        </plugin>
    </plugins>
</build>

springboot应用程序:

@SpringBootApplication
public class UserManagement extends SpringBootServletInitializer {

   @Override
   protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
       return application.sources(UserManagement.class);
   }

   public static void main(String[] args) {
       SpringApplication.run(UserManagement.class, args);
   }
}

和基本控制器:

@RestController
@RequestMapping("/")
public class UserController {
    @GetMapping
    public String test(){
        return "it works";
    }
}

有人知道怎么操作吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题