gpt4 book ai didi

java - 如何在 Maven 中跳过生成源

转载 作者:搜寻专家 更新时间:2023-10-31 20:02:36 26 4
gpt4 key购买 nike

有没有办法在 Maven 中跳过生成源代码?

通过命令行选项完成

最佳答案

我遇到过当 WSDL 或 WADL 发生变化时生成 CXF 类的场景。因此,我会在需要时显式生成它。因此,我创建了一个单独的配置文件,一个新的配置文件 cxf-gen 以及我常用的 dev、uat、syst。它具有用于生成类的插件。简而言之,每当我需要重新生成类时,我都会切换到配置文件并运行 generate-sources。这是我使用的示例配置文件。

<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<envName>dev</envName>
</properties>
</profile>
<profile>
<id>uat</id>
<properties>
<envName>uat</envName>
</properties>
</profile>

<profile>
<id>jaxB-gen</id>
<properties>
<envName>dev</envName>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<!-- CONFIGS ->
</configuration>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>code-gen</id>
<properties>
<envName>dev</envName>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<!-- CONFIGS ->
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- wadl2java Required only when JAXRS classes are to be generated -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-wadl2java-plugin</artifactId>
<version>2.7.6</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<!-- CONFIGS ->
</configuration>
<goals>
<goal>wadl2java</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.googlecode.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>0.3.7</version>
<configuration>
<!-- CONFIGS ->
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
</profiles>

关于java - 如何在 Maven 中跳过生成源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22172230/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com