我有一个包含4个模块和一个父POM的maven项目。在"mvn clean package“之后,生成4个jar文件:
application-0.0.1-SNAPSHOT.jar
domain-0.0.1-SNAPSHOT.jar
exposition-0.0.1-SNAPSHOT.jar
infrastructure-0.0.1-SNAPSHOT.jar但是,我想在tomcar服务器上部署这个应用程序。我试着在父pom中添加这个,但是包没有工作。
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>我不知道怎么弄到战争文件..。谢谢你的帮助!
编辑
博览会包装用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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example.projetfilrouge</groupId>
<artifactId>profil-skype</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>exposition</artifactId>
<dependencies>
<dependency>
<groupId>com.example.projetfilrouge</groupId>
<artifactId>application</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- AOP dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- springfox-swagger2 dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<!-- spring-security-test dependencies -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- DevTools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
</project>发布于 2020-10-15 19:33:25
据我所知,您有一个包含4个模块的maven项目。其中只有一个是exposition,另一个可能是内部库项目。
您需要更改您的pom.xml公开模块。添加
<artifactId>exposition</artifactId>
<packaging>war</packaging>这将告诉maven,您想要的是战争包,而不是Jar。
现在,您需要告诉Spring您需要一个war。更改Application类(带有@SpringBootApplicaiton注释的类如下所示)。
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class YourSpringBootApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(YourSpringBootApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
}这个SpringBootServletInitializer将配置spring来构建一个war.,现在运行mvn clean package,并且您的公开模块应该会产生一个war。这是你需要部署的战争。复制战争并将其部署到tomcat。
https://stackoverflow.com/questions/64377313
复制相似问题