Selecting class by Maven build profile

前端 未结 2 1395
夕颜
夕颜 2021-01-23 03:43

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 Ma

相关标签:
2条回答
  • 2021-01-23 04:13

    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,

    0 讨论(0)
  • 2021-01-23 04:21

    You can specify the concrete class in a property file, and filter property files by maven build profile, so they would get different values. Property file would then be read by java code and it would be used accordingly.

    Is there some reason to do this? It doesn't feel like the right way of doing things...

    0 讨论(0)
提交回复
热议问题