tomcat - Different dependency scope for webapp and standalone java app -
i'm using maven build java web application run in tomcat. jar files (e.g. mail-1.4.1.jar , database drivers) have been put in tomcat/lib directory , maven dependency set "provided". (i'm not 100% sure why, think it's jndi.)
now have built standalone executable java program in same maven project trying execute using mvn exec:java
. unsurprisingly can't find mail.jar , error java.lang.noclassdeffounderror: javax/mail/session
how specify javax.mail scope="runtime" standalone java program whilst still being "provided" tomcat app? have use maven profiles? if so, can find useful documentation on how works (are profile's dependencies additive or overwrite default ones etc?)
the raghuram answer correct, want point out something.
as sonatype wrote in blog : http://www.sonatype.com/people/2010/01/how-to-create-two-jars-from-one-project-and-why-you-shouldnt/
i want clear answer. recommend not configure maven project create 2 separate jars single project. violates 1 of important core concepts of maven: modularity.
what doing doesn't seem in "the maven way". when start stucked such problem, should think maybe not right solution chose.
there lot of topic kind of issue, around dealing multiple artifacts 1 single pom :
handling multiple artifacts single maven project
maven: attaching multiple artifacts
...
and there 1 how deal multiple environnement profile, raghuram suggested : maven best practice generating artifacts multiple environments [prod, test, dev] ci/hudson support?
so, advise split project, thinking real realationship between them. may drive multimodule project like
parent | +--project:jar | +--web-app:war
...
take here : http://www.sonatype.com/books/mvnex-book/reference/multimodule.html
good luck :)
Comments
Post a Comment