Reputation: 545
I've a Maven web application developed with Eclipse, in my pom.xml
file I've defined 2 different profiles: production and development, with different properties. When I do a clean install
to create my WAR bundle, thanks to filteringDeploymentDescriptors
in my maven-war-plugin
I manage to have a parsed web.xml with all the properties correctly substituted.
The problem is when I publish my webapp to the built in Eclipse tomcat that I'm using, that way the web.xml
isn't parsed at all and I have all raw properties name.
I've set activeByDefault
to true in my development profile and I've also set the Active Maven Profile (Properties >> Maven), but I still can't get it to work.
Upvotes: 0
Views: 773
Reputation: 8823
I think of this solution:
The idea is to change your application's web root path for Eclipse:
<project>/.settings/org.eclipse.wst.common.component
file.Set the defaultRootSource
as:
Open in an external editor the <project>/pom.xml
file.
Add within the <build>
tag:
<resources>
<resource>
<directory>src/main/webapp</directory>
<filtering>false</filtering>
<targetPath>../../target/m2e-wtp/web-resources</targetPath>
<excludes>
<exclude>WEB-INF</exclude>
</excludes>
</resource>
</resources>
Open your project in Eclipse and try it.
With this scheme, you get that Eclipse keeps your project automatically built, and on every build it calls Maven to do the resources filtering. Then, Maven does a double filtering:
filteringDeploymentDescriptors=true
).src/main/webapp
files (by the <resources>
tag).
... And the result will be outputed to the target/m2e-wtp/web-resources
directory, which is now the place where Eclipse hopes to find the web resources.WARN: There is just one drawback: You shall not execute your JSPs from src/main/webapp
, because that is no more a web container directory. Instead, you should open a browser and enter the URL you want to open.
I tried it with "build automatically" turned on, and it worked: I executed a JSP which reads init parameters from web.xml
, and I also executed clean package
and it produced a right war.
Upvotes: 0