我在将我的spring引导应用程序部署到tomcat时遇到了问题,尽管我的IDE运行得很好。我遵循了https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html的指示
但是结果,我得到了一个war包,它只包含框架库和web类,而不是来自我的核心模块。
我不确定我的pom文件是否正确。
我的项目结构如下:
portal
-web
-src
pom1.xml
-core
-src
pom2.xml
pom0.xml项目pom (头0.xml):
<modules>
<module>core</module>
<module>web</module>
<module>tests</module>
</modules>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.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>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>web模块pom (头1.xml):
<parent>
<artifactId>portal</artifactId>
<groupId>com.portal</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.portal</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>核心模块pom (头2.xml)
<parent>
<artifactId>portal</artifactId>
<groupId>com.portal</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.custom.api</groupId>
<artifactId>common-utils</artifactId>
<version>1.1</version>
</dependency>
</dependencies>UPDATE1
更详细的结构:
-web
-com.portal.web
-controller
IncidentController
ComputerController
...
-core
-com.portal.core
-domain
Incident
Computer
...mvn清除包会导致错误:
[INFO] portal ............................................. SUCCESS [ 0.700 s]
[INFO] core ............................................... SUCCESS [ 2.478 s]
[INFO] web ................................................ FAILURE [ 0.458 s]
[INFO] tests .............................................. SKIPPED
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project web: Compilation failure: Compilation failure:
[ERROR] /.../portal/web/src/main/java/com/portal/web/controller/IncidentController.java:[4,37] package com.portal.core.domain does not exist
[ERROR] /.../portal/web/src/main/java/com/portal/web/controller/IncidentController.java:[5,38] package com.portal.core.service does not exist
[ERROR] /.../portal/web/src/main/java/com/portal/web/controller/IncidentController.java:[18,19] cannot find symbol
[ERROR] symbol: class IIncidentService
[ERROR] location: class com.portal.web.controller.IncidentController
... 发布于 2017-05-11 09:59:13
多模块项目的解决方案是将Boot的重新打包配置为将分类器应用于jar:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>这个问题的全部描述是这里
发布于 2017-05-10 08:34:19
将"web模块“添加到父”门户模块“的模块部分:
<modules>
<module>core</module>
<module>api</module>
<module>tests</module>
<module>web</module>
</modules>在父“门户模块”的文件夹中运行mvn clean package。
https://stackoverflow.com/questions/43886648
复制相似问题