通过Maven构建配置文件选择类 [英] Selecting class by Maven build profile
问题描述
我想为默认的Maven构建配置文件中激活验证测试创建一个存根类。
目前我有两个同名的课程,但是在不同的包中。是否可以通过设置maven构建配置文件参数在构建阶段选择正确的类来使用?我也在我的项目中使用EJB和JSF2.0,并在其中一个bean中创建身份验证对象:
AuthUtil util = new AuthUtil();
有可能,有一些脚步。您必须将您的课程放在依赖关系中,并以这种方式使用个人资料:
<个人资料>
<个人资料>
< id> default< / id>
<依赖关系>
< dependency> ...< / dependency>
< / dependencies>
< / profile>
<个人资料>
< id> someotherprofile< / id>
<依赖关系>
< dependency> ...< / dependency>
< / dependencies>
< / profile>
< / profiles>
此外,这些类必须在同一个包中才能正常工作。
干杯,
I am quite new to Maven and Java EE programming all-together.
I would like to create a stub class for authentication testing which should be activated in the default Maven build profile.
Currently I have two classes with same name but in different packages. Is it possible to somehow select the correct class to use in the build phase by setting maven build profile parameters? I am also using EJB and JSF2.0 in my project and the authentication object is created in one of the beans:
AuthUtil util = new AuthUtil();
It is possible, with some footwork. You will have to put your class(es) in a dependency and use the profiles in this manner:
<profiles>
<profile>
<id>default</id>
<dependencies>
<dependency>...</dependency>
</dependencies>
</profile>
<profile>
<id>someotherprofile</id>
<dependencies>
<dependency>...</dependency>
</dependencies>
</profile>
</profiles>
Also, the classes will have to be in the same package for this to work.
Cheers,
这篇关于通过Maven构建配置文件选择类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!