我有一个使用 Spring Boot 的多模块 maven 应用程序:
- spring boot parent
    - myproject parent (both parent and module pom)
        - module1
        - module2
        - module-it (integration tests)
在我的 module-it 中,我将其他模块添加到我的依赖项中,并按如下方式配置 maven-failsafe-plugin:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
当我用 maven 构建我的项目时,我得到“构建成功”:
mvn clean install
到现在为止还挺好。
但是我希望我的每个模块在构建结束时都是一个可执行的 jar。使用上述设置,清单未定义且 jar 不可执行。为了解决这个问题,我在 module1 和 module2 pom 文件中添加了以下内容:
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>
有了这个设置,我的 jar 文件是可执行的,但我不能再构建了。我在我的模块中使用的类 - 它没有找到。
[ERROR] Failed …在Maven多模型中,我们有一个父pom,其中模块在<modules>tag中定义,在每个模块中,我们定义父pom是谁.
为什么这个双向定义?
为什么不在模块的父部分中定义它们之间的关系?
如果模块总是绑定到父模块,我应该如何重用模块?
我有两个Maven项目,一个叫做项目数据,另一个叫项目-rest,它依赖于项目数据项目.
Maven构建在项目数据项目中是成功的,但在项目休息项目中失败,例外情况如下:
Caused by: org.hibernate.DuplicateMappingException: duplicate import: TemplatePageTag refers to both com.thalasoft.learnintouch.data.jpa.domain.TemplatePageTag and com.thalasoft.learnintouch.data.dao.domain.TemplatePageTag (try using auto-import="false")
我可以在这里看到一些解释:http://isolasoftware.it/2011/10/14/hibernate-and-jpa-error-duplicate-import-try-using-auto-importfalse/
我不明白的是,为什么在构建项目数据项目时不会发生此消息,而在构建项目休息项目时会发生此消息.
我试着查看pom.xml文件,看看是否有什么可以解释这个问题.
我还查看了测试配置的方式并在项目休息项目上运行.
但我还没有看到任何东西.
编辑:添加Maven项目: www.learnintouch.com/learnintouch-data.tar.gz www.learnintouch.com/learnintouch-rest.tar.gz
我的Maven项目有多个Maven模块。这些模块中的两个(产品和功能)相互依赖。当我将模块作为依赖项包含在pom文件中时,一个!标记出现在模块上。在运行maven安装时,出现此错误。
The projects in the reactor contain a cyclic reference: Edge between 
'Vertex{label='com.catalog:feature:0.0.1-SNAPSHOT'}' and 
'Vertex{label='com.catalog:product:0.0.1-SNAPSHOT'}' introduces to 
cycle in the graph com.catalog:product:0.0.1-SNAPSHOT --> 
com.catalog:feature:0.0.1-SNAPSHOT --> com.catalog:product:0.0.1-
SNAPSHOT @
如果不添加依赖项,产品将无法访问功能模块中定义的功能,反之亦然。
父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>com.catalog</groupId>
    <artifactId>catalog</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.enterprise</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.4.1.Final</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency> 
        <dependency> …