Error for maven-compiler-plugin in eclipse - maven-compiler-plugin

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>

Related

How to stop Maven from downloading all historical versions of aws-java-sdk?

I am using Maven to download aws-java-sdk dependency for version 1.11.23, though in Maven repository I find all historical versions till most recent ones; i.e. aws-java-sdk-sqs downloaded versions (1.9.0 to 1.11.642) any idea why is that and how can I limit to only the version specified for aws-java-sdk artifact?
This "dependency loop" is a problem with some older versions of aws-lambda-java-events, which is probably a dependency of your dependency.
Try updating or your dependencies to the latest, or overriding aws-lambda-java-events to at least 2.2.7:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>2.2.7</version>
</dependency>
For me, After specifying the BOM of AWS SDK in the dependencyManagement section & the version I would like to use, The historical downloads were stopped. Below are my dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.10.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
I created a project (with Maven 3.5.4) with just:
<project ... >
....
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.23</version>
</dependency>
</dependencies>
</project>
All of ~/.m2/repository/com/amazonaws/* (as declared in aws-java-sdks POM) contain just the sub-directory /1.11.23.
UPDATE
To exclude dependencies of your dependencies see Introduction to the Dependency Mechanism, Transitive Dependencies:
Excluded dependencies - If project X depends on project Y, and project Y depends on project Z, the owner of project X can explicitly exclude project Z as a dependency, using the "exclusion" element.

I can't import logging dependancy into my project

The import statements aren't working
I am new to Maven so I'm not sure what to do (if I'm missing a dependancy or something)
Add this in the dependency section of your pom :
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
There are other logging libraries available ,refer :
https://www.baeldung.com/java-logging-intro
If you are using Spring, I'm not sure if need to add it. When I add the line
Log log = LogFactory.getLog(MYCLASS.class);
to a class & I choose "Import class" in IntelliJ, I can see that it refers to org.springframework:spring-jcl:5.0.5.RELEASE, so it seems to already be available through the Spring.jar .
If you want to try adding it you can add the following to your dependencies list in the pom:
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
I would also point you to Log4j which is very popular & efficient. If you want to use that you need to do two things:
Add the dependencies to the pom:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.3</version>
</dependency>
Add a log4j.properties or log4j.xml file with configurations to the classpath (mine is in sr/main/resources).

Need Guidance Building and Using oauth Jar

I have various projects in which I need to authenticate using oauth, so I downloaded oauth2 from here: http://supergsego.com/apache/oltu/org.apache.oltu.oauth2/
I simplistically assumed that in order to use oauth2, I need to create a jar file with the functionality and include it on the class path for my projects.
I'm a complete maven beginner, but I built the project by changing to the directory with pom.xml and issued the command mvn package.
That created a directory called target with a jar file called org.apache.oltu.oauth2.client-1.0.0.jar and a number of subdirectories, each with their own jar file.
My question is: Do I need include only org.apache.oltu.oauth2.client-1.0.0.jar on my class path, or does org.apache.oltu.oauth2.client-1.0.0.jar have dependencies on the jars in the sub-directories, thereby requiring that I include those jar files too?
Thanks!
I tried adding the parent dependency:
<oltu.oauth2.version>1.0.1</oltu.oauth2.version>
...
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.parent</artifactId>
<version>${oltu.oauth2.version}</version>
<type>pom</type>
</dependency>
but it didn't work coz it couldn't find the jar file on the maven repo. So I tried adding the dependencies for each individual module:
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.common</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.httpclient4</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.dynamicreg.client</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.dynamicreg.common</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.resourceserver</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.resourceserver-filter</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.dynamicreg.server</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.jwt</artifactId>
<version>${oltu.oauth2.version}</version>
</dependency>
and voila! it worked! Just comment out a module that you don't need to trim down your dependency list.

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).

Stop downloading jar form Repository 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 :(

Resources