【发布时间】:2017-01-05 06:57:53
【问题描述】:
我有以下maven结构
parent POM.XML
- common/pom.xml
- search/pom.xml
当我在 search 模块上执行 mvn clean install 时,搜索模块无法获取 common 模块类
我得到package de.test.common does not exists。我什至在父平台上运行mvn clean install,但没有成功。 common 模块构建良好。
<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>de.test.search</groupId>
<artifactId>search</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>de.test.platform</groupId>
<artifactId>platform</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<app-name>search</app-name>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>de.test.common</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>searchdev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- log configuration -->
<logback.loglevel>DEBUG</logback.loglevel>
</properties>
</profile>
<profile>
<id>searchprod</id>
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<appName>${app-name}</appName>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- log configuration -->
<logback.loglevel>INFO</logback.loglevel>
</properties>
</profile>
</profiles>
</project>
普通绒球
<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>de.test.common</groupId>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>de.test.platform</groupId>
<artifactId>platform</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<app-name>common</app-name>
</properties>
<profiles>
<profile>
<id>commondev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<!-- log configuration -->
<logback.loglevel>DEBUG</logback.loglevel>
</properties>
</profile>
<profile>
<id>commonprod</id>
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<appName>${app-name}</appName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<!-- log configuration -->
<logback.loglevel>INFO</logback.loglevel>
</properties>
</profile>
</profiles>
</project>
我想我也有这里提到的同样的问题
找到问题但没有找到原因
我删除了以下依赖,一切正常
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
删除插件后,jar 会以不同的结构构建。当 spring boot 插件存在时,整个内容都在 BOOT-INF 文件夹中,我认为这是原因,但不确定......这里需要专家意见。
【问题讨论】:
-
您是否安装了“通用”模块(到本地存储库 - mvn clean install)
-
是的,我在 \.m2\repository\de\test\common\common\0.0.1-SNAPSHOT 下有 jar
-
粘贴“common”的pom...
-
粘贴先生。请看一下。
-
有点奇怪,我刚刚用上面相同的设置运行 mvn clean install 运行良好
标签: maven pom.xml parent-pom