才開始上手maven,遇到了好多的問題,折磨了我三天了,所以寫個隨筆記錄一下解決方法
解決方法0:
最近阿里給的鏡像倉庫好像在變啊,讓我也有點憂傷.先把阿里的倉庫地址貼出來: https://maven.aliyun.com/mvn/guide
索性把自己用的maven鏡像倉庫地址貼出來:
<mirrors>
<mirror> <id>nexus-aliyun</id> <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
</mirrors>
我最開始遇到的問題都是通過插一根能上網的網線解決,所以解決問題前一定要插網線,wifi用的太痛苦了。這也有利於你網上搜解決方法
問題一:
Some problems were encountered while building the effective model for cn.itcast:travel:war:1.0-SNAPSHOT
'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 129, column 21
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.
解決方法:
檢查自己的pom.xml文件中的maven-compiler-plugin 是否寫正確了,我就是沒有忘了寫<version></version>,下面是完整代碼
<!--jdk編譯插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf-8</encoding>
</configuration>
</plugin>
問題二:
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ travel ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
解決方法:
先看看idea的編碼吧,雖然不是這個問題,看看的好。
上面的compiler文件中是否添加了<encoding>標簽並指定為UTF-8
下面這個可能才是解決問題的根本辦法:在pom.xml中的<project>標簽下添加下面這段代碼,如下圖
<project>
<properties>
<project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding>
</properties>
</project>
問題三:
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project travel:
Failed to clean project:
Failed to delete D:\IdeaProjects\itcast\travel\target\tomcat\logs\access_log.2020-03-06
解決方法:
不能清除log,那應該就是log被某個程序占用了,所以不能清除,看看啟動的項目程序沒有關閉,我就是忘記了關閉Tomcat7服務器
問題四:
編譯警告-Xlint:unchecked
解決方法:
在pom.xml中添加如下代碼
<build> <plugins> <plugin> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <compilerArgument>-Xlint:unchecked</compilerArgument> </configuration> </plugin> </plugins> </build>