Using the properties tag within maven profiles

北城以北 提交于 2019-12-03 05:46:31

Will this create a .properties file?

No, it won't. This would set the properties used by maven. This is, with mvn install -Denvironment.type=development maven would use the value 'development_user' for the variable 'database.user' (that you can use as ${database.user} in poms and filtered resources).

If not how and where will tomcat (for instance) read the individual properties when the app is tested in dev?

The thing is to tell maven to filter (and modify) the resources that you want to customize depending on the profile (properties.files).

So, first you have to say maven to filter the resources:

<build>
    <resources>
        <resource>
             <directory>src/main/resources</directory>
             <filtering>true</filtering>
        </resource>
    </resources> 
</build>

Then modify your properties files to use maven variables. For example, your db properties file would look like this:

database.driverClassName=${database.driverClassName}
database.url=${database.url}
#...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!