想用Visual Studio Code结合Maven开发WebAPP,就集成一下试试。按照https://blog.youkuaiyun.com/CSUstudent007/article/details/103433387方法集成。但是构建Maven项目时候,老是提示错误。
https://repo.maven.apache.org/maven2/.error=Could not transfer artifact org.apache.maven.plugins\:maven-archetype-plugin\:pom\:3.1.2 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/3.1.2/maven-archetype-plugin-3.1.2.pom
期间还出先各种 connect timeout错误。各种搜索,感觉应该是网络镜像的问题。找到了这篇文章。https://blog.youkuaiyun.com/pkx1993/article/details/86691426,在里面找到了解决方法。在maven的settings.xml配置文件mirrors里面加入
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
再次构建maven项目:
mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-webapp" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4"
然后下载插件都正常了。提示输入groupid等内容,最后提示构建成功:
Define value for property 'groupId': QMapWS
Define value for property 'artifactId': QMapWS
Define value for property 'version' 1.0-SNAPSHOT: : 1.0-SNAPSHOT
Define value for property 'package' QMapWS: :
Confirm properties configuration:
groupId: QMapWS
artifactId: QMapWS
version: 1.0-SNAPSHOT
package: QMapWS
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: maven-archetype-webapp:1.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: QMapWS
[INFO] Parameter: artifactId, Value: QMapWS
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: QMapWS
[INFO] Parameter: packageInPathFormat, Value: QMapWS
[INFO] Parameter: package, Value: QMapWS
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: QMapWS
[INFO] Parameter: artifactId, Value: QMapWS
[INFO] Project created from Archetype in dir: E:\Maven-Workspace\QMapWS\QMapWS
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:24 min
[INFO] Finished at: 2020-04-23T10:13:20+08:00
[INFO] ------------------------------------------------------------------------