Vimax
V2EX  ›  Java

maven 插件里面的版本依赖怎么传递

  •  
  •   Vimax · Jun 30, 2020 · 1559 views
    This topic created in 2146 days ago, the information mentioned may be changed or developed.

    版本管理的 Pom 文件里面,加入平 flyway 插件和其依赖的 mysql 驱动。

    版本号传递时,plugin 的版本号可以传递过去,但是 plugin 里面依赖的 dependency,即 Mysql 的版本号无法传递过去,使用 maven 命令就报错。已经刷新多次 maven 依赖了。

    当指定子工程中 flyway 插件下的 mysql 驱动版本号时,错误就没有了。一删除版本号,错误又恢复了。

    [ERROR]     'build.plugins.plugin[org.flywaydb:flyway-maven-plugin].dependencies.dependency.version' for mysql:mysql-connector-java:jar is missing. @ line 78, column 33
    
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.2.6.RELEASE</version>
                    <configuration>
                        <fork>true</fork>
                        <addResources>true</addResources>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>${flyway.version}</version>
                    <executions>
                        <!--当 install 时会执行 migrate-->
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>migrate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>${mysql.version}</version>
                        </dependency>
                    </dependencies>
    
                    <configuration>
                        <driver>com.mysql.jdbc.Driver</driver>
                        <url>jdbc:mysql://xxipxx:xxportxx/xxdb.schemaxx?useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false</url>
                        <user>root</user>
                        <password>1234</password>
                        <!--<schemas></schemas>-->
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        </build
    

    在子工程中,加入对应的

       <build>
            <plugins>
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <executions>
                        <!--当 install 时会执行 migrate-->
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>migrate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <driver>com.mysql.jdbc.Driver</driver>
                        <url>jdbc:mysql://xxipxx:xxportxx/xxdb.schemaxx?useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false</url>
                        <user>root</user>
                        <password>1234</password>
                        <!--<schemas></schemas>-->
                    </configuration>
                </plugin>
            </plugins>
        </build
    
    1 replies    2020-07-03 20:23:53 +08:00
    hantsy
        1
    hantsy  
       Jul 3, 2020
    父子关系 Plugin 依赖可能是个特例,Maven 目前应该是不传递的。另外父子同名的 Profile 好像也有类似的依赖问题。这个还是查一下文档比较好。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 13:12 · PVG 21:12 · LAX 06:12 · JFK 09:12
    ♥ Do have faith in what you're doing.