have eclipse, tomcat, maven and project with modules
the parent is pom
module 1 is jar (it's dependency for other modules)
module 2-7 - war
in parent pom have some dependencies with scope provided
when i build WARs - get lightweight files without deps
but if i run tomcat server in eclipse with modules 2-7 - tomcat don't load maven dependencies
i don't understand,what i should wrote in parent pom for lightweight WARs and load jars in debug together
help,please
UPDATE
solve with 2 profiles and 1 parameter as scope for all deps
If you mark a dependency as provided, you say that the container (Tomcat in your case) will provide it.
Maven will not do that for you, but you need to configure it yourself in Tomcat.
Related
I have the following error when deploying and starting the application with Wildfly.
No EJB found with interface of type "de.dev.java.project.api.ProjectApi" for binding de.dev.java.project.restservice.ProjectRestService/projectApi.
Project module structure:
- project-api -> built as jar
- ProjectApi.java
- project-impl -> built as jar
- ProjectRestService.java
{
#EJB ProjectApi projectApi
}
- application -> built as ear, which includes modules above
I only have a problem when i build "project-impl" module as jar. When i built as war i do not have a problem. What does war include which jar does not?
You must build as a proper ejb jar, not just regular jar. It also needs to be referenced properly in the ear. Use you IDE to setup suitable maven project with the right archetype
I have a spring boot project that run correctly when launched from maven mvn -P dev spring-boot:run.
When I start it as a java application it fails because of several ClassNotFoundException. It's due to the fact that some dependencies belong to dev maven profile so they're not present in Maven Dependencies that eclipse put in classpath when it launchs java appication.
So the question is: how can I obtain the correct Maven Dependencies choosing a particular maven profile?
child module has below dependency so this alfresco-repository-5.1.1-tests.jar is coming that i can see in Maven dependencies in eclipse.I will use this jar only for compiling test classes.
<groupId>org.alfresco</groupId>
<artifactId>alfresco-repository</artifactId>
<version>5.1</version>
<classifier>tests</classifier>
<scope>test</scope>
I have parent module which will generate war which has this child module has dependency.so this jar is coming also in war.
so how to exclude this jar in war?
When you package a Maven project to a WAR file, you don't package any dependencies mentioned within your pom.xml inside your WAR. your WAR file will include your pom.xml and your .class files in it, without dependencies.
If you need that dependency for testing purposes only, the test scope
<scope>test</scope>
is enough. That'll include the requested dependency in your classpath only when running your JUnits or any other tests. You can verify that if you'll execute the test phase & compile phase separately in debugging mode, and make sure that in test phase it's being included in your classpath, and in compile phase, it doesn't. To debug the test phase in command-line:
mvn -X test
I have a root project that builds WAR, and two child projects that build JARs. The root project references the child project in this way:
apply plugin: 'war'
jar.enabled = false
war {
dependencies {
runtime project(':application1')
runtime project(':application2')
}
}
application2 depends on application1:
dependencies {
compile '...:application1:1.+'
}
The WAR file includes two versions of application1.jar: one from repository, another just built.
EDIT: Application2 has to depend on application1 as a JAR because that simplifies debugging in Eclipse with embedded Jetty: Eclipse automatically adds application1.jar to classpath of Jetty server launch configuration.
You have specified dependency on application1 project differently for the root project and for the application2.
For your application2 it was made as dependency on a library within some repository, but your root project depends on it as on a subproject. Gradle can't determine, that some library in the repo is the same, as subproject's artifact.
If you don't want to get 2 versions of the same lib, you have to make it dependent from the same library: either as
compile '...:application1:1.+'
or as
runtime project(':application1')
Anyway, it seems to be prefferable, to make it depending on the same subproject in both cases, rather then on some project and on the library in repo.
Eclipse Indigo; m2e 1.1.0; Maven integration for WTP 0.15.3; Maven 3.0.4
My web project has some dependency projects in the same workspace. All projects are installed. When i run maven install, except to see all dependencies in WEB-INF/lib.
When i run maven install plugin or maven war plugin, the WEB-INF/lib will be filled with dependencies, but they are a lot more than i expected, from the "dependency Hierarchy" or "Effective POM" view of the POM file, or from Maven dependencies in classpath view, i can not find the dependencies.
Run Maven->update projects does not help.
So where these dependencies come from or where should i start to debug?
EDIT
Previously my project has a large dependency tree(100+ jars), some of them are not needed, so i decided to remove them. My project depends on a common project, which has some not needed dependencies, i remove them from POM dependencies and run maven install for the whole projects dependency tree, success. then i run maven install on my project, it should not include the jars i removed from the common project, but, unfortunately they are there in WEB-INF/lib.
If you want to know where your dependencies are coming from, run:
mvn dependency:tree
from the command line. This shows how transitive dependencies are pulled in from your declared dependencies.
You can also run:
mvn dependency:analyze
to see if you can remove any unused dependencies to lessen the number of JARs packaged.
Problem solved, I delete the whole project and import from remote, run maven-install, it worked. Still have no idea why it not work before even after i run "maven clean install" on all dependency projects.