日常Maven报错信息汇总

问题1
编译项目报错:不再支持源选项 5。请使用 6 或更高版本
解决方式
<!--在pom文件中检查编译版本是否指定正确 参考spring parent包配置-->
  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
问题2:
//测试web工程代码时报错
java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig
解决方式
<!--包匹配问题 使用的spring5.3.10版本与依赖servlet-api不兼容
<dependency>  
	<groupId>javax.servlet</groupId>  
    <artifactId>servlet-api</artifactId>  
</dependency>  
可替换为下方包
-->
<dependency>
  <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>test</scope>
</dependency>
问题3
  2021-10-11 22:07:27,957 [qtp1226858597-39] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Failed to complete request: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.setContentLengthLong(J)V
  [WARNING] 
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.setContentLengthLong(J)V
    at org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:1082)
    at org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:963)
    at org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:735)
    at org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:883)
解决方式:
<!--包匹配问题 我原来使用的版本是jetty8+,使用的spring5.3.10版本与插件jetty版本不兼容,spring5.3.10依赖servlet3.1,jetty插件9以下版本不支持servlet3.1
可替换为下方包
-->
 <plugin>
  <groupId>org.eclipse.jetty</groupId>
     <artifactId>jetty-maven-plugin</artifactId>
     <version>9.4.32.v20200930</version>
     <configuration>
         <scanIntervalSeconds>10</scanIntervalSeconds>
         <webApp>
             <contextPath>/test</contextPath>
         </webApp>
         <httpConnector>
             <port>8081</port>
         </httpConnector>
     </configuration>
 </plugin>
问题4
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (attach-javadocs) on project flink-connector-starrocks: MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
解决方式:
<!--指定对应的javahome-->
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-javadoc-plugin</artifactId>
     <version>2.9.1</version>
     <executions>
         <execution>
             <id>attach-javadocs</id>
             <goals>
             	<goal>jar</goal>
             </goals>
             <configuration>
   				<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
             </configuration>
         </execution>
     </executions>
 </plugin>
问题5
Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar (make-a-jar) on project common: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [Help 1]
解决方式:
<!--插件打包和项目打包名称重复需要指定一个差异化后缀-->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <classifier>bak</classifier>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <outputDirectory>./target/</outputDirectory>
    </configuration>
</plugin>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值