V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Vimax
V2EX  ›  Java

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

  •  
  •   Vimax · 2020-06-30 10:49:47 +08:00 · 1112 次点击
    这是一个创建于 1388 天前的主题,其中的信息可能已经有所发展或是发生改变。

    版本管理的 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 条回复    2020-07-03 20:23:53 +08:00
    hantsy
        1
    hantsy  
       2020-07-03 20:23:53 +08:00
    父子关系 Plugin 依赖可能是个特例,Maven 目前应该是不传递的。另外父子同名的 Profile 好像也有类似的依赖问题。这个还是查一下文档比较好。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3155 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 14:17 · PVG 22:17 · LAX 07:17 · JFK 10:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.