关于修改本地中央仓库位置网上很容易找到(修改Maven配置文件settings.xml)。在很久很久以前,我也修改过,也确定修改成功了。但是今天在执行mvn clean install时,我的项目一直被打包安装在默认的本地中央仓库。我仔细检查了你一遍又一遍,最后确定自己的配置没问题。于是想通过命令行的形式查看并修改下本地仓库的位置。这么已查看就发现了问题。 我的 maven 是放在 D:\Java\apache-maven-3.5.3 目录下
查看maven配置的命令: mvn -X
D:\Java\IdeaProjects\dubbo-interface>mvn -X
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:0
5+08:00)
Maven home: F:\masterSpring\apache-maven-3.5.3\bin\..
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: D:\Java\jdk1.8.0_181\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG] Imported: javax.annotation.* < plexus.core
[DEBUG] Imported: javax.annotation.security.* < plexus.core
[DEBUG] Imported: javax.enterprise.inject.* < plexus.core
[DEBUG] Imported: javax.enterprise.util.* < plexus.core
[DEBUG] Imported: javax.inject.* < plexus.core
[DEBUG] Imported: org.apache.maven.* < plexus.core
[DEBUG] Imported: org.apache.maven.artifact < plexus.core
[DEBUG] Imported: org.apache.maven.classrealm < plexus.core
[DEBUG] Imported: org.apache.maven.cli < plexus.core
[DEBUG] Imported: org.apache.maven.configuration < plexus.core
[DEBUG] Imported: org.apache.maven.exception < plexus.core
[DEBUG] Imported: org.apache.maven.execution < plexus.core
[DEBUG] Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG] Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG] Imported: org.apache.maven.model < plexus.core
[DEBUG] Imported: org.apache.maven.monitor < plexus.core
[DEBUG] Imported: org.apache.maven.plugin < plexus.core
[DEBUG] Imported: org.apache.maven.profiles < plexus.core
[DEBUG] Imported: org.apache.maven.project < plexus.core
[DEBUG] Imported: org.apache.maven.reporting < plexus.core
[DEBUG] Imported: org.apache.maven.repository < plexus.core
[DEBUG] Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG] Imported: org.apache.maven.settings < plexus.core
[DEBUG] Imported: org.apache.maven.toolchain < plexus.core
[DEBUG] Imported: org.apache.maven.usability < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG] Imported: org.codehaus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.* < plexus.core
[DEBUG] Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.component < plexus.core
[DEBUG] Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG] Imported: org.codehaus.plexus.container < plexus.core
[DEBUG] Imported: org.codehaus.plexus.context < plexus.core
[DEBUG] Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG] Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG] Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.cor
e
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < p
lexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.cor
e
[DEBUG] Imported: org.eclipse.aether.* < plexus.core
[DEBUG] Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG] Imported: org.eclipse.aether.collection < plexus.core
[DEBUG] Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG] Imported: org.eclipse.aether.graph < plexus.core
[DEBUG] Imported: org.eclipse.aether.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.installation < plexus.core
[DEBUG] Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG] Imported: org.eclipse.aether.repository < plexus.core
[DEBUG] Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG] Imported: org.eclipse.aether.spi < plexus.core
[DEBUG] Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG] Imported: org.eclipse.aether.version < plexus.core
[DEBUG] Imported: org.fusesource.jansi.* < plexus.core
[DEBUG] Imported: org.slf4j.* < plexus.core
[DEBUG] Imported: org.slf4j.helpers.* < plexus.core
[DEBUG] Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo pro
ject
[DEBUG] Reading global settings from F:\masterSpring\apache-maven-3.5.3\bin\..\c
onf\settings.xml
[DEBUG] Reading user settings from C:\Users\zcf\.m2\settings.xml
[DEBUG] Reading global toolchains from F:\masterSpring\apache-maven-3.5.3\bin\..
\conf\toolchains.xml
[DEBUG] Reading user toolchains from C:\Users\zcf\.m2\toolchains.xml
[DEBUG] Using local repository at D:\Java\repo
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\J
ava\repo
[INFO] Scanning for projects...
[DEBUG] Extension realms for project com.example.demo:dubbo-interface:jar:1.0-SN
APSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.c
ore, parent: null]
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
com.example.demo:dubbo-interface:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boo
t-maven-plugin is missing. @ line 13, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.176 s
[INFO] Finished at: 2019-11-02T23:51:40+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid li
fecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id
>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are
: validate, initialize, generate-sources, process-sources, generate-resources, p
rocess-resources, compile, process-classes, generate-test-sources, process-test-
sources, generate-test-resources, process-test-resources, test-compile, process-
test-classes, test, prepare-package, package, pre-integration-test, integration-
test, post-integration-test, verify, install, deploy, pre-clean, clean, post-cle
an, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specifie
d for this build. You must specify a valid lifecycle phase or a goal in the form
at <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-ver
sion>]:<goal>. Available lifecycle phases are: validate, initialize, generate-so
urces, process-sources, generate-resources, process-resources, compile, process-
classes, generate-test-sources, process-test-sources, generate-test-resources, p
rocess-test-resources, test-compile, process-test-classes, test, prepare-package
, package, pre-integration-test, integration-test, post-integration-test, verify
, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site
-deploy.
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt
arter.java:94)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jav
a:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessor
Impl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche
r.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2
29)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc
her.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356
)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifie
dException
请看第 84 - 89 行,这里加载的是 F:\masterSpring\apache-maven-3.5.3 下的配置文件,而F:\masterSpring\apache-maven-3.5.3根本不是我自己的Maven(不知道哪来的)。
问题发现了:是使用的 maven 有问题,这个Maven(F:\masterSpring\apache-maven-3.5.3 )我根本没有修改过本地仓库路径,也不知道他是哪来的。
问题解决:
方法1:修改F:\masterSpring\apache-maven-3.5.3 这个Maven的配置文件中的默认仓库路径。
方法2:修改环境变量中的 Maven 路径,改成我自己的Maven D:\java\apache-maven-3.5.3 。