6

我正在尝试使用以下命令更新我的 Spring Boot 项目中特定依赖项的版本。但是依赖版本没有得到更新。这是我正在使用的命令:

mvn versions:use-latest-snapshots -Dincludes=com.example:drools-sample-proj

Spring Boot 项目的依赖:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>drools-sample-proj</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

我的本地 Maven 存储库.m2文件夹包含 2 个版本drools-sample-proj

  • 0.0.2-快照
  • 0.0.3-快照

我的 Spring Boot 项目pom.xml没有0.0.3-SNAPSHOT使用此构建命令更新该依赖项:

mvn versions:use-latest-snapshots -Dincludes=com.example:drools-sample-proj

构建控制台日志:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building springboot-rule-service 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- versions-maven-plugin:2.2:use-latest-snapshots (default-cli) @ springboot-ruleservice-api ---
[INFO] Incremental version changes allowed
[INFO] Incremental version changes allowed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.800 s
[INFO] Finished at: 2018-02-03T23:25:58-06:00
[INFO] Final Memory: 23M/377M
[INFO] ------------------------------------------------------------------------

Spring Boot 版本:1.5.9

Spring Boot 项目的pom.xml

<build>
    <finalName>springboot-rule-service</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我在 Spring STS IDE 中使用嵌入式 Maven。我在这里遗漏了什么还是我对更新的理解pom.xml不正确?任何见解都会有所帮助。

使用 mvn use-latest-versions 命令后的日志。

使用此命令时出现异常: mvn versions:use-latest-versions -Dincludes=com.example.brms:drools-sample-proj -X

[DEBUG]   (s) project = MavenProject: com.example.brms:springboot-ruleservice-api:1.0 @ C:\Drools Workspace\sprinboot-ruleservice-api\pom.xml
[DEBUG]   (f) reactorProjects = [MavenProject: com.example.brms:springboot-ruleservice-api:1.0 @ C:\Drools Workspace\springboot-ruleservice-api\pom.xml]
[DEBUG]   (f) remoteArtifactRepositories = [      id: central
      url: http://mavencentral.Xxx.com/content/groups/public/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => daily]
]
[DEBUG]   (f) remotePluginRepositories = [      id: central
      url: https://repo.maven.apache.org/maven2
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => never]
]
[DEBUG]   (f) serverId = serverId
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@790132f7
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@48b0e701
[DEBUG] -- end configuration --
[INFO] Major version changes allowed
[INFO] Major version changes allowed
[DEBUG] Looking for newer versions of com.example.brms:drools-sample-proj:jar:0.0.1-SNAPSHOT
[DEBUG] Determining update check for artifact com.cccis.brms:tvr-rules (C:\Users\smuthuku\.m2\repository\com\example\brms\drools-sample-proj\maven-metadata-central.xml) from central (http://mavencentral.company.com/content/groups/public/)
[DEBUG] Searching for central.maven-metadata-central.xml.lastUpdated in resolution tracking file.
[DEBUG] Reading resolution-state from: C:\Users\smuthuku\.m2\repository\com\example\brms\drools-sample-proj\resolver-status.properties
[DEBUG] Error releasing shared lock for resolution tracking file: C:\Users\smuthuku\.m2\repository\com\example\brms\drools-sample-proj\resolver-status.properties
**java.nio.channels.ClosedChannelException**
    at sun.nio.ch.FileLockImpl.release(FileLockImpl.java:58)
    at org.apache.maven.repository.legacy.DefaultUpdateCheckManager.read(DefaultUpdateCheckManager.java:396)
    at org.apache.maven.repository.legacy.DefaultUpdateCheckManager.readLastUpdated(DefaultUpdateCheckManager.java:323)
    at org.apache.maven.repository.legacy.DefaultUpdateCheckManager.readLastUpdated(DefaultUpdateCheckManager.java:159)
    at org.apache.maven.repository.legacy.DefaultUpdateCheckManager.isUpdateRequired(DefaultUpdateCheckManager.java:148)
    at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.resolve(DefaultRepositoryMetadataManager.java:124)
    at org.apache.maven.project.artifact.MavenMetadataSource.retrieveAvailableVersions(MavenMetadataSource.java:434)
    at org.apache.maven.project.artifact.MavenMetadataSource.retrieveAvailableVersions(MavenMetadataSource.java:424)
    at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupArtifactVersions(DefaultVersionsHelper.java:389)
    at org.codehaus.mojo.versions.UseLatestVersionsMojo.useLatestVersions(UseLatestVersionsMojo.java:128)
    at org.codehaus.mojo.versions.UseLatestVersionsMojo.update(UseLatestVersionsMojo.java:95)
    at org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo.process(AbstractVersionsUpdaterMojo.java:322)
    at org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo.execute(AbstractVersionsUpdaterMojo.java:257)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] artifact com.example.brms:drools-sample-proj: checking for updates from central
[DEBUG] repository metadata for: 'artifact com.example.brms:drools-sample-proj' could not be found on repository: central
[DEBUG] Reading resolution-state from: C:\Users\smuthuku\.m2\repository\com\example\brms\drools-sample-proj\resolver-status.properties
[DEBUG] Writing resolution-state to: C:\Users\smuthuku\.m2\repository\com\example\brms\drools-sample-proj\resolver-status.properties
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.246 s
[INFO] Finished at: 2018-02-06T10:59:17-06:00
[INFO] Final Memory: 23M/310M
[INFO] ------------------------------------------------------------------------
4

2 回答 2

4

目标versions:use-latest-snapshots仅更新发布版本,请参阅推进依赖版本

versions:use-latest-snapshots在 pom 中搜索所有已是较新的 -SNAPSHOT 版本的非 SNAPSHOT 版本,并用最新的 -SNAPSHOT 版本替换它们。

但在你的 POM 中是一个快照版本:

Spring Boot 项目的依赖:

<dependency>
     <groupId>com.example</groupId>
     <artifactId>drools-sample-proj</artifactId>
     <version>0.0.1-SNAPSHOT</version>
</dependency>

所以依赖关系没有改变。

您可以使用目标versions:use-latest-versions,请参阅版本 Maven 插件

用最新版本替换任何版本。

您修改后的命令行:

mvn versions:use-latest-versions -DallowSnapshots=true -Dincludes=com.example:drools-sample-proj
于 2018-02-06T16:27:14.480 回答
1

这个我用过,这个命令会更新pom中的所有版本!

mvn versions:display-dependency-updates
于 2020-03-03T11:54:01.553 回答