代码之家  ›  专栏  ›  技术社区  ›  Angelina

Maven在被聚合器pom调用时无法读取子模块的资源

  •  1
  • Angelina  · 技术社区  · 7 年前

    我运行了几个模块” mvn clean install “必须维持他们的秩序。让我的生活更轻松,不必改变 TFS 或者别的什么,我想创造 project aggregator 那将是我的全部 sub-modules ,而他们对此一无所知 aggregator . 我的项目结构:

    projectaggregator
    |
    +- submodule1
    |
    +- submodule2
    

    聚合器/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>com.my.package</groupId>
        <artifactId>projectaggregator</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>pom</packaging>
        <name>Project Aggregator</name>
    
        <modules>
            <module>../submodule1</module>
            <!--<module>../submodule2</module>-->       
        </modules>
    </project>
    

    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] submodule1
    [INFO] Project Aggregator
    [INFO] 
    [INFO] Using the MultiThreadedBuilder implementation with a thread count of 8
    [INFO]                                                                         
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Project Aggregator 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] Building submodule1 1.0.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- swagger-codegen-maven-plugin:2.3.1:generate (default) @ submodule1 ---
    [INFO] reading from src/main/resources/yaml/decision.yaml
    [INFO] reading from src/main/resources/yaml/decision.yaml
    [ERROR] failed to read resource listing
    java.io.FileNotFoundException: src\main\resources\yaml\decision.yaml (The system cannot find the path specified)
        at java.io.FileInputStream.open0(Native Method)
    ...
    [INFO] No .swagger-codegen-ignore file found.
    [ERROR] java.lang.RuntimeException: missing swagger input or config! 
    
    ...
    [INFO] --------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] submodule1 ....................................... FAILURE [  3.983 s]
    [INFO] Project Aggregator ............................... SUCCESS [  0.003 s]
    [INFO] --------------------------------------------------------------------
    [INFO] BUILD FAILURE
    

    子模块1/pom.xml:

    ...
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.3.RELEASE</version>
        </parent>
        <dependencies>
            <dependency>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.3.1</version>
            </dependency>
        ...
    

    submodule1 聚合器 . 有什么解决办法吗 relative path 不需要修改的资源 子模块1

    1 回复  |  直到 7 年前
        1
  •  4
  •   mailtobash    7 年前

    在使用swagger执行多模块构建时,我也遇到了同样的问题。显然,在查看资源路径时,swagger插件有一个限制。 ${project.basedir} 在我们的swagger插件配置中:

    <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>2.2.1</version>
        <executions><execution>
            <goals><goal>generate</goal></goals>
            <phase>generate-sources</phase>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/yaml/decision.yaml</inputSpec>
            </configuration>
        </execution></executions>
    </plugin>
    
    

    从这里引用- https://github.com/swagger-api/swagger-codegen/issues/3583