【发布时间】:2021-07-12 21:04:09
【问题描述】:
大多数依赖于其他包的插件倾向于在插件配置中声明依赖。例如,spotbugs' doc 会这样做
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.2.0</version>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.2.3</version>
</dependency>
</dependencies>
</plugin>
spotbugs“core”的版本在plugin > dependencies > dependency中指定。
但是,flyway 似乎无法以这种方式工作。例如,数据库驱动程序位于<dependencies> 中的以下配置运行良好。
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>${flyway.version}</version>
<configuration>
<url>jdbc:mysql://localhost:3306/mydb</url>
<user>root</user>
<password>root</password>
</configuration>
</plugin>
</plugins>
</build>
问题:
- 这是否意味着依赖项(至少是编译和运行时范围的)也在构建时目标的类路径中?
- 这可能是主观的,但如果确实有最佳实践,它显然会帮助像我这样的初学者。那么在“全局”
<dependencies>标记中编写 flyway 的依赖项是好的/常见的编码风格吗?
【问题讨论】: