我正在从 Java 8 迁移到 Java 11 并遇到了这个问题。我应该使用:
但是在启动时不断出现错误:
合并bean定义后处理失败;嵌套异常是 java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
我找到了多种方法来修复它。尝试添加依赖项:
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
尝试添加扩展名:
<extensions>
<extension>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</extension>
</extensions>
Run Code Online (Sandbox Code Playgroud)
这些都没有帮助。
这是 maven-compiler-plugin 配置:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
请帮忙寻找解决办法!!
annotationProcessors:
要运行的注释处理器的名称.仅适用于JDK 1.6+如果未设置,则应用默认注释处理器发现过程.
这里的默认注释处理器发现过程是什么?有没有其他方法来设置注释处理器而不是此配置标签?
我发现注释处理工具入门(apt)文档提到了一个默认的发现过程,但它适用于工厂类而不是处理器,不幸的是它使用了JDK中的tools.jar和com.sun包.这是默认的注释处理器发现过程吗?
java maven-2 annotations annotation-processing maven-compiler-plugin
我正在尝试在 java 16.0.1 上使用 maven 构建 IntelliJ 项目,但它无法编译我的项目,尽管 IntelliJ 能够成功完成。在此之前,我使用maven编译了一个java 15项目,但我决定将所有内容更新到16.0.1,因为我的机器上不同版本的java完全混乱,就像我能够编译但不能运行生成的.jar文件一样等等
mvn compile输出:
[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper
Run Code Online (Sandbox Code Playgroud)
这是我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>TaxiDB</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>16.0.1</release>
</configuration>
</plugin>
</plugins> …Run Code Online (Sandbox Code Playgroud) 在我的多模块项目中,我module-info.java只创建了几个模块.在编译期间maven-compiler-plugin:3.7.0我得到下一个警告:
[警告]*检测到必需的基于文件名的自动模块.请不要将此项目发布到公共工件库!*
这是什么意思?是因为我只有几个模块,module-info.java而不是整个项目?
我正在学习 Selenium,我想尝试将 maven-compiler-plugin 添加到 pom.xml 并重新导入 maven 设置。所以我找到了这个例子来做到这一点http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html并尝试将代码添加到pom.xml 。但示例 3.8.1 中的 vrsion 是红色的,如屏幕截图所示。这是什么意思?它是示例的副本。
这是整个 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>camaj.vladimir</groupId>
<artifactId>selenium-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.google.code.tempus-fugit</groupId>
<artifactId>tempus-fugit</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build> …Run Code Online (Sandbox Code Playgroud) 我有两个关于maven.compiler.release-tag 的问题
我想更换
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)
到
<properties>
<maven.compiler.release>12</maven.compiler.release>
</properties>
Run Code Online (Sandbox Code Playgroud)
如果我使用<maven.compiler.release>-property,是否还必须在插件中设置发布标签?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<!-- do I need that ? -->
<release>12</release>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
根据https://www.baeldung.com/maven-java-version,它被设置为两者。
如果我使用maven.compiler.release而不是maven.compiler.sourceand maven.compiler.target,那么-bootclasspath也会被设置并且会进行交叉编译。这是什么意思?使用 set 的编译文件大小-bootclasspath会更大还是编译需要更多时间?
我有一些问题要正确配置我的eclipse与maven一起工作.
我创建了一个新项目,这个是在命令行(mvn install)中使用maven正确构建的,但是在Eclipse中我遇到了这个错误:
CoreException:无法获取参数compilerId的值,用于插件执行default-compile:PluginResolutionException:插件org.apache.maven.plugins:maven-compiler-plugin:3.1或其中一个依赖项无法解析:无法收集依赖项org.apache.maven.plugins:maven-compiler-plugin:jar:3.1():ArtifactDescriptorException:无法读取org.apache.maven的工件描述符:maven-settings:jar:2.2.1:ArtifactResolutionException:无法传输org .apache.maven:maven-settings:来自http://repo.maven.apache.org/maven2的 pom:2.2.1 缓存在本地存储库中,在中心的更新间隔已经过去或更新之前,不会重新尝试解析被迫.原始错误:无法传输工件org.apache.maven:maven-settings:pom:2.2.1 from/to central:NullPointerException pom.xml/test line 9 Maven Project Build Lifecycle Mapping问题
这是我的settings.xml conf:
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>myuser</username>
<password>$mymdp</password>
<host>myhost</host>
<port>8080</port>
<nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....
<repository>
<id>central</id>
<name>central repo m2</name>
<url>http://central.maven.org/maven2</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
我选择了正确的maven安装(在Preference - > Maven - > Install中)
我还将我的用户设置指向正确的settings.xml(首选项 - > Maven - >用户设置)
但我仍然在Eclipse中遇到此错误,并且maven命令行的一切顺利.你有想法吗?
我有一个使用Maven构建的Java项目.我想在"javac"命令行中添加选项 - 特别是,我想传递一些"-J"选项.
通常我会做这样的事情:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-J-Xdebug</compilerArgument>
<compilerArgument>-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</compilerArgument>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试这个时,我得到了表单的错误:
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid flag: -J-Xdebug
Usage: javac <options> <source files>
use -help for a list of possible options
Run Code Online (Sandbox Code Playgroud)
经过仔细研究,似乎maven-compiler-plugin将所有编译器参数写入选项文件,并调用javac,如'javac @optionfile'.根据javac的官方文档http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html:
@argfiles列出选项和源文件的一个或多个文件.这些文件中不允许使用-J选项.
所以看起来maven-compiler-plugin中的选项不起作用 - 它想要使用arg文件,arg文件不能包含我想要的选项.
我也看到了一些使用地图的建议 - 但是当我尝试它时,它有类似的结果.
还有其他选择吗?
我有一个使用Java 8的项目.
到目前为止,在pom中我们将源版本和目标版本指定为1.8:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Run Code Online (Sandbox Code Playgroud)
我们想利用Java 9+的"-release"选项并添加以下内容:
<maven.compiler.release>1.8</maven.compiler.release>
Run Code Online (Sandbox Code Playgroud)
但现在我们收到以下错误:
Fatal error compiling: release version 1.8 not supported
Run Code Online (Sandbox Code Playgroud)
我们使用maven 3.5.3,版本3.8.0和Java 10中的maven-compiler-plugin来编译项目.
这有什么不对?
也许有一个maven-compiler-plugin选择,但我没有找到它.
当javac直接运行并打印错误时,在消息的第一行之后,它会在指向错误位置的下一行显示受影响的源代码行.它看起来像这样:
com/invariantproperties/udt/sql/RationalUDT.java:324: error: cannot find symbol
public static boolean lessThan(RRationalUDT p, double q) {
^
symbol: class RRationalUDT
location: class RationalUDT
Run Code Online (Sandbox Code Playgroud)
注意直接指向我拼写错误类型名称的行.它maven-compiler-plugin显示如下:
[ERROR] /var/tmp/pljava-udt-type-extension/java/src/main/java/com/invariantproperties/udt/sql/RationalUDT.java:[324,36] cannot find symbol
symbol: class RRationalUDT
location: class com.invariantproperties.udt.sql.RationalUDT
Run Code Online (Sandbox Code Playgroud)
注意它摆脱了实际指向错误的行.(这是使用Oracle JDK 7.)
好的,所以起初我认为这个较旧的问题会得到答案,因为它也maven-compiler-plugin没有显示整个错误消息,并且说修复程序是更新到maven-compiler-plugin3.1版.
但是对于这个问题,我尝试了2.4,3.1和3.5而没有任何改进.显示错误的行总是丢失.
这适用于任何javac错误.在示例中,我拼错了一个符号,只是为了得到与旧问题所讨论的相同的错误.但我可以修复那个并制作另一个(这个来自javac注释处理器):
com/invariantproperties/udt/sql/RationalUDT.java:324: error: No known mapping to an SQL type
public static boolean lessThan(RationalUDT p, double q) {
^ …Run Code Online (Sandbox Code Playgroud)