[英]How to use class file instead of java file when compiling with maven
We received an updated .class
file but not the .java
file for a project.我们收到了更新的
.class
文件,但没有收到项目的.java
文件。 How can I ensure this new class file is used, and placed in the right directory, in the compiling of our maven pom
without affecting the project?如何确保在编译我们的
maven pom
时使用这个新的 class 文件,并将其放置在正确的目录中而不影响项目?
Getting extracted class files is highly unusual.提取 class 文件是非常不寻常的。 Normally, you get a jar and use it as dependency.
通常,您会得到一个 jar 并将其用作依赖项。 In the case you have such class files, I would manually bundle them into a jar file and upload them to your Maven repository with appropriate coordinates (groupId, artifactId, version).
如果您有这样的 class 文件,我会手动将它们捆绑到 jar 文件中,然后使用适当的坐标(groupId,artifactId, Then you can reference them as dependency in your
pom.xml
.然后,您可以在
pom.xml
它们作为依赖项引用。
Not sure if this is the best method, but i was able to accomplish using this class file as a replacement for.java and no.jar file being provided by adding this resource argument to the maven pom file. Not sure if this is the best method, but i was able to accomplish using this class file as a replacement for.java and no.jar file being provided by adding this resource argument to the maven pom file.
<resource>
<directory>${project.basedir}/src/main/java/com/action/helper</directory>
<targetPath>${project.build.directory}/classes/com/action/helper</targetPath>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.