java - 在 groovy 文件 Java 11 中导入 Java 类的问题
问题描述
我一直在尝试将应用程序迁移到 Java 11。这个应用程序有多个使用通用 pom 的模块。将主 pom.xml 重构为 Java 11 后,我无法从 Groovy 类中正确导入 Java 类,并且我不断从 mvn clean compile 中收到此错误“从类路径调用 Groovy 类的方法时发生错误。:InvocationTargetException :启动失败:”。这是我的 pom 文件配置。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>compileTests</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<formats>
<format>xml</format>
</formats>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>site</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<destFile>${project.basedir}/target/jacoco.exec</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
我究竟做错了什么?
解决方案
推荐阅读
- mysql - MySQL:使用 LONGTEXT 而不是 MEDIUMTEXT 是否缺乏性能?
- c - 函数中的变量输入类型
- python - 如何获取 Keras 模型所有层的输出?
- python - 如何在python中按字符串中的特定单词对行进行分组
- python - 如何在 python 中调用我网站上的 php 脚本?
- python - 将 hive 表卸载到。使用 Spark 或 pyspark 或 python 的 dat 文件
- python - 矩阵的平均值乘以标量向量
- python - Google App Engine:每天自动重新部署一次以更新机器学习模型?
- java - 如何从另一个类中调用同名方法?
- android - Material Component FloatingActionButton 中的 shapeAppearance 导致崩溃