开发者

Setup Tomcat libraries dependencies in maven POM

I am currently migra开发者_如何学Goting our build process from Eclipse/Ant to Maven/M2Eclipse/Artifactory. I have a Webapp as a WTP project in Eclipse. I have migrated it to Maven with m2eclipse.

The compilation runs fine from the Eclipse IDE.

However, when I try to compile from Maven CLI (mvn clean & mvn compile), Maven complains about not finding the libraries provided by the Tomcat Environment (like annotations-api, servlet-api, etc, ...).

Fair enough : Indeed, these dependencies are provided by WTP, as Java resources / Libraries / ApacheTomcat6. Maven is not aware of them.

I could deactivate this in the build path, and add each corresponding dependency in my POM, but I'm afraid this would lead Maven to deploy them again in my webapp (WEB-INF/libs).

So, what is the good way to say to maven "this application will run in a well known environment, providing the following libraries ". Is there some common Tomcat POM that I could add as a dependency ?

Thanks in advance for your advice. regards,

Raphael


One way to handle this is to declare these dependencies with scope provided. These dependencies will be available for compile and test, but will not be packaged by maven into the webapp. For example,

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜