在执行maven软件包命令后,IntelliJ中的Maven Spring Boot多模块项目无法成功构建

时间:2018-12-10 11:35:48

标签: java spring maven spring-boot intellij-idea

我在IntelliJ中有一个spring boot多模块项目,问题是,当我在IntelliJ中运行该项目时,它可以按预期的方式构建和运行,但是当我尝试使用Maven程序包时,出现此错误:

  

缺少ng.biosec:enrollment_ws:jar:0.0.1-SNAPSHOT的POM,否   可用的依赖项信息和POM   ng.biosec:abis_module:jar:0.0.1-SNAPSHOT丢失,没有依赖性   可用信息

,然后该过程失败。

这是两个模块和父模块的pom.xml: enrollment_ws.xml pom

<?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">

<parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>enrollment_ws</artifactId>
    <packaging>jar</packaging>

    <dependencies>


    </dependencies>
</project>

这是abis_module.xml pom文件:

<?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">
    <parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>abis_module</artifactId>
    <packaging>jar</packaging>



</project>

这是cpm.xml pom文件,它取决于包含上述pom文件的模块:

<?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">
    <parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cpm</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>enrollment_ws</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>abis_module</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>
    </dependencies>


</project>

cpm模块包含Spring引导应用程序类。这是Spring Application类:

@SpringBootApplication
@EnableScheduling
@EnableJpaRepositories(basePackages = {"integron"})
@ComponentScan(basePackages = {"integron"})
@EntityScan(basePackages = {"integron"})
public class BioConnectApplication {
    public static void main(String[] args) {
        SpringApplication.run(BioConnectApplication.class, args);
    }
}

这也是父pom文件:

<?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>
    <modules>
        <module>enrollment_ws</module>
        <module>cpm</module>
        <module>verification</module>
        <module>abis_module</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from integron.repository -->
    </parent>
    <groupId>ng.biosec</groupId>
    <artifactId>integron</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>integron</name>
    <description>Bio Connect Project</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- tag::wsdl[] -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>integron.client</generatePackage>

                    <schemas>
                        <schema>
                            <url>********?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>
            <!-- end::wsdl[] -->
        </plugins>
    </build>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>



</project>

也: 出于安全原因,我替换了指向WSDL文件的链接,但是maven项目也不会从WSDL生成类。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您应从 integron 模块描述符中删除<parent>元素声明,并将其移至子模块。

spring-boot-maven-plugin 仅应在包含您的 Spring Boot 应用程序的模块中声明,即 cpm 模块。

下面是 integron 项目描述符的格式:

<?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>

    <modules>
        <module>enrollment_ws</module>
        <module>cpm</module>
        <module>verification</module>
        <module>abis_module</module>
    </modules>

    <groupId>ng.biosec</groupId>
    <artifactId>integron</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>integron</name>
    <description>Bio Connect Project</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <!-- tag::wsdl[] -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>integron.client</generatePackage>
                    <schemas>
                        <schema>
                            <url>********?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>
            <!-- end::wsdl[] -->
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

cpm 模块描述符应如下所示:

<?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">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from integron.repository -->
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cpm</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>enrollment_ws</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>abis_module</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>
    </dependencies>

    <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</project>

关于 wsdl 生成的文件,我想它们是生成的,但是没有打包,因为将父模块包装设置为 pom