MAVEN项目报错解决方法集锦(1)

才开始上手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>

 

 

 

  

posted @ 2020-03-06 10:18  学渣很忙  阅读(14748)  评论(5编辑  收藏  举报