我不知道为什么我的maven构建在当前pom设置中不会生成目标/类,在我的情况下包装类型必须是"pom",请告知错误...谢谢!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.sm.doctor</groupId>
<artifactId>smdoctor</artifactId>
<packaging>pom</packaging>
<version>${SMDOCTOR_VERSION}</version>
<name>sm doctor</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<debug>true</debug>
<debuglevel>source,lines</debuglevel>
<showDeprecation>true</showDeprecation>
<archive>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>smdoctor</finalName>
<descriptors>
<descriptor>dist.xml</descriptor>
<descriptor>zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/smdoctor.zip</file>
<type>zip</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> …Run Code Online (Sandbox Code Playgroud) 当我忘记在Serializable类中声明serialVersionUID时,我想让我的Maven构建失败.有javac,这很容易:
$ javac -Xlint:serial -Werror Source.java
Run Code Online (Sandbox Code Playgroud)
直接将其翻译为Maven不起作用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<compilerArgument>-Xlint:serial -Werror</compilerArgument>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
的compilerArgument被引用,因此javac仅接收一个参数,包含-Xlint:serial -Werror代替,-Xlint:serial并-Werror作为单独的参数.所以你阅读了文档,并找到compilerArguments:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<compilerArguments>
<Xlint:serial />
<Werror />
</compilerArguments>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这看起来很奇怪 - 冒号serial在Xlint命名空间中创建了元素,它没有在任何地方声明 - 但是它有效...直到你想要发布一个版本:
$ mvn release:prepare
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project my-project: Error reading POM: Error on line 58: The prefix "Xlint" for …
我是一个mavenifying(是一个单词?)一个项目,其构建过程到目前为止完全基于ant/shell脚本.
请考虑以下枚举
public enum ResourceType {
A, B;
}
Run Code Online (Sandbox Code Playgroud)
以下bean:
public ResourceTypeOwner {
//set get resourceType property
}
Run Code Online (Sandbox Code Playgroud)
以下代码片段:
void foo(ResourceTypeOwner rto) {
ResourceType resourceType = rto.getResourceType();
switch (resourceType) {
case A:
handleA(resourceType); break;
case B:
handleB(resourceType); break;
default:
throw new RuntimeException("Unsupported resource type");
}
}
Run Code Online (Sandbox Code Playgroud)
使用maven构建时出现编译错误:
无法打开ResourceType类型的值.只允许使用可转换的int值或枚举变量
pom.xml具有以下用于编译的插件配置
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerId>eclipse</compilerId>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
Run Code Online (Sandbox Code Playgroud)
ant(与org.eclipse.jdt.core.JDTCompilerAdapter)和eclipse构建/编译都很好.我显然做错了(除非它是一个未报告的maven-compiler-plugin或plexus-compiler-eclipse插件bug,这有点不太可能,切换枚举既不坏也不是火箭科学).有人有想法吗?
其他环境细节
$ mvn -version Apache Maven 3.0.4(r1232337; 2012-01-17 10:44:56 …
我今天已经更新到IntelliJ 14.0.1。我导入了我在IntelliJ 13.1上工作的Maven项目,尽管成功导入了该项目,但是当我尝试从IntelliJ Make或Compile从IntelliJ获得该项目时却找不到依赖项。
我需要说的是,即使从IntelliJ内部进行Maven安装,也成功。但是,当我Make出现项目错误时,表明缺少库(依赖项)。
在我看来,以某种方式从IntelliJ进行的编译步骤不会吸收Maven依赖项,或者没有考虑pom.xml到这一点。
有没有人遇到过类似的事情?关于如何解决该问题的任何想法?我已经尝试过重新导入该项目,但没有帮助。另外,我创建了一个仅将JUnit作为依赖项的虚拟项目,但是即使这样,IntelliJ仍在抱怨说,org.junit.Test当我尝试运行测试时找不到。
我在IntelliJ日志中看到以下内容,这可能是相关的。好像编译被中止了。
2014-11-14 17:17:11,460 [247914]信息-j.compiler.server.BuildManager-BUILDER_PROCESS [stdout]:17:17:11,445 | -ch.qos.logback.classic.LoggerContext中的INFO [默认]-在[jar:file:/ C:/ Program%20Files%20(x86)/JetBrains/IntelliJ%20IDEA%20Community%20Edition%2014.0.1/plugins/gradle/lib/gradle.jar中找到资源[logback.groovy]! /logback.groovy]
2014-11-14 17:17:11,460 [ 247914] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: 17:17:11,446 |-ERROR in ch.qos.logback.classic.LoggerContext[default] - Groovy classes are not available on the class path. ABORTING INITIALIZATION.
2014-11-14 17:17:13,459 [ 249913] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 5; warnings: 0 took 2652 ms: 0 min 2sec
Run Code Online (Sandbox Code Playgroud) compilation intellij-idea maven maven-compiler-plugin intellij-14
我一直在尝试升级我的 JHipster 5 应用程序以使用 Java 10,但我无法让它使用 Maven 编译和处理 JPA 静态元模型。
\n\n显然maven-compiler-plugin不是hibernate-jpamodelgen为了生成 JPA 静态元模型而触发。
为了升级项目,我有:
\n\n<java.version>10</java.version> 升级了 maven-compiler-plugin 以添加java.xml.bind模块(因为从 Java 10 开始默认不包含该模块),如下所示:
<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>${maven-compiler-plugin.version}</version>\n <configuration>\n <!-- fork is needed so compiler args can be used -->\n <fork>true</fork>\n <compilerArgs>\n <arg>-J--add-modules</arg>\n <arg>-Jjava.xml.bind</arg>\n </compilerArgs>\n <annotationProcessorPaths>\n <path>\n <groupId>org.mapstruct</groupId>\n <artifactId>mapstruct-processor</artifactId>\n <version>${mapstruct.version}</version>\n </path>\n <!-- For JPA static metamodel generation -->\n <path>\n <groupId>org.hibernate</groupId>\n <artifactId>hibernate-jpamodelgen</artifactId>\n <version>${hibernate.version}</version>\n </path>\n\n </annotationProcessorPaths>\n …Run Code Online (Sandbox Code Playgroud)我尝试使用 Maven 编译器插件创建存储库https://github.com/olehmberg/WebTableStitching的 jar ,但出现以下错误:
Exception in thread "main" java.lang.StackOverflowError
at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:691)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:579)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:271)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
at java.io.PrintStream.write(PrintStream.java:526)
at java.io.PrintStream.print(PrintStream.java:669)
at java.io.PrintStream.println(PrintStream.java:806)
at org.slf4j.impl.SimpleLogger.write(SimpleLogger.java:381)
at org.slf4j.impl.SimpleLogger.log(SimpleLogger.java:376)
at org.slf4j.impl.SimpleLogger.info(SimpleLogger.java:538)
at org.apache.maven.cli.logging.Slf4jLogger.info(Slf4jLogger.java:59)
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:464)
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:467)
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:467)
...
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED …Run Code Online (Sandbox Code Playgroud) 我的项目需要访问内部 JDK 类,特别是内部 JavaFX 类。这在 Eclipse 中没有问题,因为我可以将所需的 Java 9 模块添加到构建路径中。问题出现在Maven构建过程中。我收到类似错误
class file for com.sun.javafx.binding.ExpressionHelperBase not found
Run Code Online (Sandbox Code Playgroud)
当我尝试研究解决方案时,我遇到了术语问题。Maven 和 Java 都使用“模块”这个词,但它们描述的东西不同。我指的是Java 9 模块。是否可以像使用库一样在 pom.xml 中添加对此类模块的依赖项?
编辑:该问题已被标记为可能重复。澄清一下,我并不是想更改 Maven 项目的 Java 版本。我需要的内部 JDK 类在默认配置中无法访问。它们是内部 Java 模块的一部分,必须在构建路径中指定该模块,以便在 Eclipse 中进行开发时可以访问。现在我需要知道如何告诉 Maven 包含此模块,以便成功构建我的项目,该项目(再次)依赖于属于此模块的类。
java maven-3 maven maven-assembly-plugin maven-compiler-plugin
如何在 pom 文件中配置 OpenJDK 11。
<properties>
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有 3 个这样的模块:
permissions (parent pom)
|---permission-api (just api, without main spring class)
|---permission-service (spring boot app)
Run Code Online (Sandbox Code Playgroud)
在主模块的父pom中,我有pom,其中包含:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>permissions-api</module>
<module>permissions-service</module>
</modules>
Run Code Online (Sandbox Code Playgroud)
和一些依赖项。现在我想用 Maven clean install 构建我的整个项目。Permission-api模块已构建(lombok注释没有问题)。在 pom 中,对 lombok 的唯一引用是:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)
无论如何,当我尝试仅构建权限服务或整个项目时,我遇到了如下编译错误:
cannot find symbol
[ERROR] symbol: method getPermissionsList()
[ERROR] location: variable employee of type permissions.model.entity.Employee
Run Code Online (Sandbox Code Playgroud)
我知道我应该将 maven-compiler-plugin 添加到 pom.xml (我也尝试将其添加到父 pom 中),我这样做了,但没有帮助:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId> …Run Code Online (Sandbox Code Playgroud)