How can I import external *.jar in spring mvc project using maven? - eclipse

I followed this correct answer in how to add local jar using maven, But I get 404 not found.
POM.Xml
<dependency>
<groupId>tn.mass</groupId>
<artifactId>massTer</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
eclipse console error

Check in your .m2 folder if massTer.jar is present with correct group id and version. Ideally if you are owning the source project massTer then I would suggest you to user maven-install-plugin to get it installed within your .m2 folder when you run mvn clean install over that project. Instead of building the jar and later adding it as mvn install:install

Related

Spring boot 1.4.1 Maven Eclipse Error 88252

I use Eclipse Neon, configured with embedded maven 3.3.9
When I add to my pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
and I try to run Maven Update I get the error:
An internal error occurred during: "Updating Maven Project".
88252
And the dependency jars are not added to Maven Dependencies tree.
If I run mvn clean package -U it builds correctly, both from command line and Eclipse (Run As Maven..)
If I change back to 1.4.0.RELEASE everything works fine!
Any Idea?
The problem was related to some broken package in my local maven repository.
I delete the entire <home_dir>/.m2/repository/org/springframework/ directory, I ran Maven Update again and everything turned normal!

Why does addition of MigLayout still give an error inspite of adding the MigLayout jar file in the libraries in netbeans 8.0?

Though I have configured the classpath and added the jar file in the library of the project , it still gives me an error as "package net.miginfocom.swing. does not exist".
What can I do to avoid this error?
You can use maven to automatically download MigLayout. Just click new project, select and maven from categories, then Java Application. Once created go into the "pom.xml" (within Project Files) and paste this under the properties section:
<dependencies>
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout</artifactId>
<version>3.7.4</version>
</dependency>
</dependencies>
Then just build the project and maven will download and install MigLayout. Hope this helps.

eclipse cannot find the jar available in maven dependencies

I have a pom.xml with the following entry
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
And on maven install the jar is added to the maven repository and is also listed in the maven dependencies library.
But I am not able to import any of the classes from the added jar 'spring-web-3.1.0.RELEASE.jar' for the particular entry, though it shows in the classpath
The error - in eclipse "cannot be resolved to a type"
environment - maven 3.1 and Spring tool suite
Thanks
Solved - found the solution through some other forum
The jar inside the repository was corrupted.
After clearing the .m2 folder in the physical drive and repeating the maven clean install worked.
Thanks for the time #techidiot #jtravaglini.

eclipse buildpath error with maven dependency

In my pom.xml i have the following dependency
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>3.2.8</version>
</dependency>
My eclipse download the jar file as expected and my code compiles just fine. But when i execute my JUnit tests i'm gettin a exception wich is the cenario expected for when the dependency is missing.
If i change the dependency to
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>3.2.8</version>
<scope>system</scope>
<systemPath>\path\to\wstx-asl-3.2.8.jar</systemPath>
</dependency>
the issue persists. But when i remove the dependency from the pom.xml and add it to the builpath using the standard eclipse way everything works just fine.
Executing a mvn package the tests are executed just fine. Only when i run them in the eclipse envirionment that the issue occurs.
what am i missing here?
Eclipse has a separate build path. When using maven projects within Eclipse you need to rebuild the build path that Eclipse uses to point to the downloaded Maven artifacts.
You do this by running mvn eclipse:eclipse on your project and then clean and build your project from within eclipse.
This Maven plugin rebuilds your .classpath file within your project, this file stores your build path.
See: http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html

Eclipse Project with Dependency Management by Maven

I have a Eclipse project where Maven manages the dependencies. I have also few jar files that are not Maven enable and I locate them at src/main/webapp/WEB-INF/lib. I have no issue to build/run the project in Eclipse. I have no issue also to run "mvn:package" after I built the project in Eclipse. However, after I invoke "mvn:clean", if I run "mvn:package", I will get compilation error as it can't find dependency jar files under src/main/webapp/WEB-INF/lib. What I need to do is to rebuild the Eclipse project then "mvn:package". Therefore, I can't invoke "mvn:package" outside Eclipse IDE.
How to resolve this?
Thanks.
You have to put the not "Maven enabled artifacts" to an appropriate Maven Repository (Nexus, Artifactory what ever) and than change your project to use the dependencies appropriately. Furthermore either you do Maven or not but nothing in between. Maven is a build tool and not only for dependency management. After those changes working with Eclipse will work fine (if you use M2Eclipse). If you correctly use Maven you can do both things via Eclipse or call mvn package on command line.
If you can not set up a recommended environment (maven repository) you can add the dependencies as System dependencies to your pom.xml.
<project>
...
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.2.3</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/foobar.jar</systemPath>
</dependency>
</dependencies>
...
</project>