maven does not copy dependencies - maven

I have Dynamic Web Application project in eclipse that was converted to maven project.
Problem is that all dependencies are copied to:
<project>/target/<project>-SNAPSHOT/WEB-INF/lib
not <project>/WebContent/WEB-INF/lib
so when I run application from eclipse, there are no libs from maven and I get some errors.
I assume that application started from eclipse i.e on tomcat server gets it source from <project>/WebContent/WEB-INF/lib.

You should use m2e (Maven Plugin for Eclipse). It automatically adds Maven dependencies to the classpath, so you donĀ“t need them in /WEB-INF/lib while running from Eclipse.

Related

Issue in Maven java swing build in Netbeans

I am working on a Netbeans Maven Java Application in Netbeans. not able to build a java swing application. Dependency are not downloading in .m2 folder.
.
Add the above code in the setting.xml file (C:\Users\PC.m2\settings.xml)

Spring Boot with Maven Install vs Eclipse Export WAR

I hardly use Maven.The only time for me to use it is for maintaining my web app dependencies.
Now I started to develop web app using Spring Boot. I notice when I run Maven install, a WAR file will be created in the target folder. Then I export WAR using File > Export on my STS IDE and compare the two wars. The size of the 2 files are different. How can this be ? Also, the WAR file created from Maven runs fine on standalone Tomcat 7 while the exported war from Eclipse (STS) doesn't.
What am I missing here ?
It's reasonable to assume that WTP (File > Export > Web etc) would produce a different WAR file from the maven build. Maven build may have plugins applied to the build to produce the desired WAR file. Check your POM file carefully and check if there are any maven plugins used in the build.
Now, I don't exactly know how Eclipse WTP component produces their WAR file (Export WAR file is not from STS - it's Eclipse WebToolsProject) from the project. There might be options in the export wizard to play around with or some configuration file in your project. You'd better off asking that on the Eclipse forum: https://eclipse.org/forums/index.php?t=thread&frm_id=88
Hope this helps.

Locally installed jar is not included in my IDEA tomcat deployment

My IDEA project compiles and builds just fine when I compile using IntelliJ.
For some reason, when I deploy to tomcat using an exploded-war, 1 jar I have isn't included in the deployment and my spring app fails to load because it can't find the class.
The jar in question is a locally installed maven dependency i.e. on my laptop
Could this be the reason why it is being skipped by IDEA? It maybe tries to find the jar using maven, but since it is local is can't and skips it?
How can I fix this?
The IDEA project is a maven module and builds fine.
Put that jar into the libs folder of tomcat or embed it into your own jar using maven assembly plugin. https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html

Deploy MavenWebApp in Eclipse Tomcat

I have the following Problem:
I have a Maven MainProject with some SubProjects.
Two of this SubProjects are WebApplications. (One WebApp and one WebService)
If I build the MainProject in the command line with mvn clean package the 2 .war files are deployable in an external Apache Tomcat 6.0.
If I build the MainProject in eclipse with the m2e plugin i can also deploy the .war files into an external Tomcat.
BUT if i want to deploy the WebProjects in an Apache Tomcat in Eclipse, it doesn't boot.
The Problem is, that the file structure of the eclipse build for the internal Tomcat is different to the Maven one.
In the Maven build (console / m2e) the path is correctly from e.g. Project/src/main/java/com/... to WEB-INF/com...
The eclipse build for the internal Tomcat creates the structure like WEB-INF/main/java/com/...
So many of the .xml files which are mandatory for the Tomcat boot are not found bacause of the wrong path.
How can i tell eclipse that it should do the similar build like m2e or maven on command line so that i can use an internal tomcat in eclipse?
I am using
Eclipse Juno 4.2 or Helios 3.6
m2e - Maven Integration for Eclipse / 1.1.0.20120530-0009 / org.eclipse.m2e.feature.feature.group
Maven Integration for WTP / 0.15.2.20120306-2040 / org.maven.ide.eclipse.wtp.feature.feature.group
I fixed the problem.
The problem was the deployment assembly options in the eclipse projects.
Eclipse default option is to deploy /src to / folder.
Because of the maven structure /src/main/java/com the deployed folder also looks like /main/java/com.
I only had to change the source folder from /src to /src/main/java (the destination still remains /). If there are other necessary files i had to add them the same way, e.g. /src/main/resources.
The /src/main/webapp folder was already set correctly by eclipse to /WEB-INF

Using maven jetty plugin in multi-module project under Eclipse

I am working on a simple multi module maven project under Eclipse using m2eclipse with maven 3 and jetty plugin version 7. One of my module is a jar and the other module is a war which has a dependency on the jar.
Even though the workspace dependency resolution is enabled, the call to mvn jetty:run fails if I don't run mvn install before.
Having read about workspace dependency, I am not sure why a call to mvn install is required. I would like to be able to run the jetty plugin without installing the artifacts to my local repository. Is it possible?
Thanks in advance.
There is an integration module between m2eclipse and the WTP (Web Tool Platform).
WTP allow starting Jetty/Tomcat/... from Eclipse, debugging inside Eclipse, redeploy on change,...
Here is it: m2eclipse Extras

Resources