Stop downloading jar form Repository Maven - maven

In my Maven Project I have dependency for
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
But the downloaded jar is corrupted or it has problem so my application fails. I have a working jar in my hard. So I want to add that instead of downloading form repo. I used this to do that,
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/xalan-xalan-2.7.1.jar</systemPath>
</dependency>
But didn't work :(

Related

Why is IntelliJ adding wrong maven dependency in my Spring Boot project?

When I click the import maven dependency in the pop up shown at RequestMapping, intellij adds
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.10.RELEASE</version>
</dependency>
But it should add this.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
How can I resolve this? I have auto-import enabled for maven and I have tried both the maven bundled version with IntelliJ and the manually downloaded version.
Changing the dependency manually makes the program run correctly.
Open pom.xml
Remove the below dependency :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.10.RELEASE</version>
</dependency>
and add this :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

Error for maven-compiler-plugin in eclipse

getting error for maven-compiler-pluggin in eclipse
any solution?
As the error says you are missing one class, so you'll need to add the dependency, as is a dependency that will exist on server mark it as provided to indicate maven to use it in compile time but not include it in the generated artifact (provided by deploy environment). Try adding this dependency in your project pom.xml:
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
Hopes this helps.
You have to include the servlet-api-xxx.jar in your dependencies.
Maven
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>

Eclipse plugin- Maven transitive dependency issue

I am facing issue with velocity jar issue. As one of the eclipse plugin dependent on CXF bundle.
jar dependency defined in pom.xml as below,
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.5</version>
</dependency>
another eclipse plugin dependent on custom bundle jar which has
jar dependency defined in pom.xml as below,
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
On runtime I am geting issue as,
Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
To identify the issue I run the command,
mvn dependency:tree -Dverbose
This shows maven omitting velocity jar from cxf as it loads another velocity in classpath.
How to resolve this jar dependency ?
use the <exclusions> tag for the dependency you not want:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.5</version>
<exclusions>
<exclusion>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<exclusion>
<exclusions>
</dependency>

I have some missing jar files in my .m2 folder of maven.

Can I download the whole .m2 folder from the internet in place of downloading single jar file?
Remember...
Over the classical way (put a dependency inside a pom and delegate to maven the download)
You have two way to copy a jar into m2
1: The "manual one" just download the jar an put inside the file inside .m2 under the correct path..
2: The official one----> http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
I'm not understanding ...
If I've to make Spring application ...
I put all the dependencies inside my pom.xml .... like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- A project with Spring MVC, JPA and Hibernate SessionFactory -->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>MavenWeb</groupId>
<artifactId>MavenWeb</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<description></description>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
</dependency>
<!-- dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version> </dependency -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.10</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
</dependencies>
<properties>
<org.springframework.version>3.0.2.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
</plugin>
</plugins>
</build>
</project>
When I run the Maven install, maven downloads from the remote central repository to the jar it needs to run the application...
in this way you've downloaded all the jars you need inside your .m2 folder...
That's the usual use of Maven dependencies management ....
but if it's does not help you, maybe I'm not understanding your problem...
If jars are missing which you placed in pom.xml and you want to download, then Right click on your project and run as "Maven Install" it will download the missing jars.
Maybe the actual JAR file you are looking for is not provided in the release, but the POM file is. In that case, until you explicitly tell Maven to use the BOM file to import the needed library, the former will only set up a correct folder hierarchy in your .m2 repository, but with nothing interesting in it.
See the official documentation for the correct lines of code to do so. Here is an example dealing with the org.codehaus.groovy:groovy-all:2.5.9 library (see the top-right item for the Apache Maven lines of code).

How to exclude a dependency from remote mavenpom?

I have a local pom which uses mahout-0.8 dependency. Mahout pom includes hadoop-core dependency with 1.1.2 version. Link to mahout-0.8 pom
But in my project I need the latest hadoop-core, which is 2.2.0 version. As I have read hadoop-core-2.2.0 is built from these dependencies:
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>2.2.0</version>
</dependency>
So I need to exclude dependency from remote mahout-0.8 dependency. How to exclude this dependency (snipped) or it cannot be done remotely?
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
...
</dependency>
If it cannot be done in such way, would like to know how to integrate mahout pom to my local project.
Many thanks!
Copy the hadoop-core dependency in your second snippet into the dependencyManagement section of your pom. This will manage it to whatever version you specify.
Or, if you really really want to stop it from coming from mahout all together, change your mahout dependency to something like the following:
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout</artifactId>
<version>0.8</version>
<exclusions>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
</exclusion>
</exclusions>
</dependency>

Resources