I\'m trying to filter a Spring configuration file using Maven filtering. My POM is configured like this:
...
I just had a similar problem. My solution is not elegant and I am not proud of it, but let's say it is acceptable. In my case I have a spring boot mvc application with swagger application (for testers to test our API). The thing is we are using this app in two environments, so I created two profiles - dev and test. In dev env we would like to fire application from eclipse with just "run as" so the context path is blank (I know it can be set in spring java config, but it is not the only placeholder we would like to switch) and in test env the application is run in our customized version of tomcat... so the context path is the same as war file name.
and here is the problem - swagger is calling rest docs on this context path and it depends on spring profile. So we have a web resource that needs to be filtered. At first I tried to use m2e-wtp filtering:
...
org.apache.maven.plugins
maven-war-plugin
true
src/main/webapp
**/scripts.js
...
it was working but only run in embedded in eclipse tomcat or from commandline java -jar it was not working with "run as" from eclipse.
The resource was filtered and I saw them in web-resource in target, but eclipse seems to be running on a source code directly or is making a copy I do not know... it cannot see filtered resources... so I thought that I will make something like this:
src/main/resources
true
src/main/resources/webapp/swagger
${basedir}/src/main/webapp/swagger
scripts.js
It is not most fortunate solution, because it is modifing code and not the target, but at least it is working. If anyone would have any suggestions how to make it work without code modifications I would be greateful.