我在Spring Boot中部署应用程序时遇到了一些问题。我有以下应用程序结构。总共有三个项目 第一个项目是项目Parent,它的包类型是war 第二个项目是简单的天气,它的包装类型是pom(我将来会添加一些maven模块) 第三个项目是simple-webapp,它的包类型是pom(我将来会添加更多的maven模块)
简单天气和简单webapp都添加为父pom中的依赖
这是代码
父项目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>ProjectParent</groupId>
<artifactId>projectparent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<modules>
<module>simple-webapp</module>
<module>simple-weather</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.5.RELEASE</version>
</parent>
<!-- Additional lines to be added here... -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
简单weather.pom
<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>
<parent>
<groupId>ProjectParent</groupId>
<artifactId>projectparent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>simple-weather</artifactId>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>HelloWorldApplication1</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<packaging>pom</packaging>
</project>
简单webapp.pom
<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>
<parent>
<groupId>ProjectParent</groupId>
<artifactId>projectparent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>simple-webapp</artifactId>
<packaging>pom</packaging>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>HelloWorldApplication</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
所以问题是当我尝试将父pom部署到tomcat时,它会显示以下消息
[ERROR]项目ProjectParent:projectparent:0.0.1-SNAPSHOT (E:\ Dashboard \ workspace \ projectparent \ pom.xml)有1个错误[错误]
价值'战争'的'包装'无效。聚合器项目需要 'pom'作为包装。 @第6行,第14栏
有什么建议吗?
答案 0 :(得分:0)
您的父pom的<packaging>
必须为pom
,如错误消息中所述。你的simple-webapp pom的<packaging>
应该是战争。你只需要切换它们。
此值必须为父包的pom。您的父包有两个模块:simple-weather模块包含您的应用程序simple-webapp模块将此应用程序包装为可部署的war文件。