简体   繁体   English

用 Maven 原型重命名 Java class

[英]Renaming Java class with Maven Archetype

Is it possible to rename a java class using Maven?是否可以使用 Maven 重命名 java class? I'm using the Maven Archetype to generate new projects based on my model.我正在使用Maven 原型生成基于我的 model 的新项目。 I can set a new groupId, artifactId, and packages for each new project.我可以为每个新项目设置一个新的 groupId、artifactId 和包。

This is the current pom.xml inside target.这是当前pom.xml内部目标。

<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>

So, when I want to create a project Banana (artifactId) inside com.foo (groupId), it's pretty possible.所以,当我想在com.foo (groupId) 中创建一个项目Banana (artifactId) 时,这很有可能。 All I need to do is run: mvn archetype:generate (...arguments like groupId, artifactId, version)我需要做的就是运行: mvn archetype:generate (...arguments like groupId, artifactId, version)

It will generate a new project based on my archetype, renaming its packages, groupId, artifactId.它将根据我的原型生成一个新项目,重命名它的包、groupId、artifactId。 But I also want to rename some java classes , thus:但我想重命名一些java classes ,因此:

ArchetypeApplication.java should be renamed to BananaApplication.java ! ArchetypeApplication.java应该重命名为BananaApplication.java

Is there some way to do that?有没有办法做到这一点?

You can only specify a class name if the archetype supports this feature.如果原型支持此功能,您只能指定 class 名称。 For example:zk-archetype-theme defines the "theme-listener-class" property for this.例如:zk-archetype-theme为此定义了“theme-listener-class”属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM