I am very very new to Maven. I get the following error
The following artifacts could not be resolved: stax:stax:jar:1.0, stax:stax-ri:jar:1.0, clover:clover:jar:1.3-rc4: Failure to find stax:stax:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
After some research (e.g. NetBeans: Re-run Maven with the -e switch on / PluginResolutionException), it is said that I need to edit my ~/.m2/settings.xml file.
I look at the file and I don't see what to change. So I am including it below for input:
settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
User-specific configuration for maven. Includes things that should not
be distributed with the pom.xml file, such as developer identity, along with
local settings, like proxy information. The default location for the
settings file is ~/.m2/settings.xml
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--proxies>
<proxy>
<host>my.proxy.host</host>
</proxy>
</proxies-->
<!--pluginGroups>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups-->
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schoolsupplies.v5</groupId>
<artifactId>com.schoolsupplies.v5.test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.schoolsupplies.v5.test</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.14</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>20040902.021138</version>
<type>jar</type>
</dependency>
</dependencies>
I open the dependencies directories and delete all the jars that were making trouble -- especially since they were not explicitly called for in the pom.xml file. After doing that, everything works fine.
It seems that maven decided that some of my explicitly imported dependencies needed those files. In my case: stax:stax-ri:jar:1.0, clover:clover:jar:1.3-rc4, etc.
I hade the same error. I added the repositories into the pom.xml and everything worked.
Like this example:
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repositories>
Related
Heroku supports open JDK 15 https://devcenter.heroku.com/changelog-items/1887
I have a system.properties that contain java.runtime.version=15 in my resource. Here my pom.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ma</groupId>
<artifactId>currencyconverter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>currencyconverter</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- For Json Parser -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- For swagger-annotations -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.17</version>
</dependency>
<!-- springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<!-- springfox-core -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-core</artifactId>
<version>3.0.0</version>
</dependency>
<!-- springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<!-- Swagger dependency -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When the deployment starts in Heroku first few line of logs:-
-----> Building on the Heroku-20 stack
-----> Java app detected
-----> Installing JDK 1.8... done
-----> Executing Maven
$ ./mvnw -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO] Downloading from central:
https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.3/spring-boot-starter-parent-2.4.3.pom
Why is it installing JDK 1.8?
Last few line of the log:-
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project currencyconverter: Fatal error compiling: invalid target release: 15 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
Push rejected, failed to compile Java app.
Push failed
How do I deploy the JDK 15 app in Heroku?
I have a system.properties that contain java.runtime.version=15 in my resource.
You placed it in /src/main/resources.
You are supposed to place it in the root folder / of your git repo.
In my case the content of my system.properties is java.runtime.version=10.0.2 and is placed in the root directory of my git repo.
In the build.log immediately after Java app detected it should install the specified Java version:
Maven is unable to download jar (s) (Dependency) behind proxy.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.faizan.firstbootapp.group1</groupId>
<artifactId>com-faizan-firstbootapp-group-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FirstBootApp</name>
<description>Test app for Maven build system</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is my settings.xml at path C:\Users\faizanmubasher\.m2\settings.xml. I have added proxies in it.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>skm--http-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>my.proxy.ip.here</host>
<port>8080</port>
<username>faizanmubasher</username>
<password>*****</password>
</proxy>
<proxy>
<id>skm--https-proxy</id>
<active>true</active>
<protocol>https</protocol>
<host>my.proxy.ip.here</host>
<port>8080</port>
<username>faizanmubasher</username>
<password>*****</password>
</proxy>
</proxies>
</settings>
Username and password are correct.
Is it due to my office's proxy that is not allowing to download jar or is it some Maven settings that I need to configure?
I am facing this error on STS IDE.
The container 'Maven Dependencies' references non existing library 'C:\Users\faizanmubasher\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE\spring-boot-autoconfigure-2.0.2.RELEASE.jar' FirstBootApp Build path Build Path Problem
My Maven version is Apache Maven 3.5.3.
EDIT
The command set MAVEN_OPTS="-DhttpProxyHost=xxx.xx.xx.xx -DsocksProxyPort=8080" doesn't work as well.
Try this, if 1 does not work try 2, then 3:
1) First update the project, Alt-F5
2) Then go to your repo and blow away the directory for that dependency which should be in the directory C:\Users\faizanmubasher.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE Then do an Alt-F5 again.
3) If this fails try a mvn clean install -U from the command line.
You can test your maven to maven central repo connectivity with the following command:
mvn archetype:generate
You should see over 2000 archetypes returned
I have encountered the same problem.
And I turned back to older versions of maven which is 3.1.0.
I was trying to use a http proxy to get reached to maven https
repository.
Here, there is a issue for newer versions in maven's jira.
https://issues.apache.org/jira/browse/PROXY-27
IntelliJ does not let me import com.microsoft even though Maven resolves the dependency and it appears as a Module in my project settings (thus should be in the classpath).
External dependency resolves:
Modules:
POM file has this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.arcologydesigns.rest</groupId>
<artifactId>ads-webapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<spring.version>4.0.5.RELEASE</spring.version>
<jdk.version>1.8</jdk.version>
<jackson.version>2.2.3</jackson.version>
<!--<sqlserver.version>4.2.6420.100</sqlserver.version>-->
<sqlserver.version>4</sqlserver.version>
<build.scm.revision>SCM_IDENTIFIER</build.scm.revision>
<build.number>BUILD_NUMBER</build.number>
<build.id>BUILD_ID</build.id>
<build.job.name>BUILD_JOB_NAME</build.job.name>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqlserver.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20120521</version>
</dependency>
</dependencies>
<build>
<finalName>ads-webapp</finalName>
</build>
</project>
I used the following to install sqljdbc driver (which I downloaded from MSDN) for Maven: http://techmajik.com/2014/04/24/how-to-setup-maven-dependency-for-microsoft-sql-server/
Try adding it directtly to Maven repository like this:
mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
and then add this to your POM.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
for more detailes you can read this topic:
http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/
You need to do this because SQL Server driver is not included in maven repository - and you need to install it yourself.
You can directly use this below dependency:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version> </dependency>
The older sqljdbc driver (v 4.0) jar file is available at the maven repo :
https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4/4.0
Download and install it using the command as mentioned by user4198625 taking care to
make sure that maven (mvn) in in your PATH
JAVA_HOME is correctly defined in your env variables (for Windows). This is expecially important if you are running the mvn batch file.
For the command to work as is, you need to execute it from the directory where the jar file is present.
I have a maven project, created using the quickstart archetype.
This is my pom.xml:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dotd</groupId>
<artifactId>marus</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>marus</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>mvnrepository.com</id>
<name>mvnrepository.com</name>
<url>http://www.mvnrepository.com/artifacts</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</project>
This is what I see in Eclipse:
The fact is that in the maven .m2 repository the jar exists and is resolved by eclipse, so I'm able to import and use classes from log4j as you can see in the following screenshot.
Why does eclipse still tell me that the artifact is missing?
UPDATE
As pointed out by Juned Ahsan, it could be a repository issue. So I did browse http://www.mvnrepository.com/artifacts and it shows a 404 error: the repository doesn't exist.
I switched to the official maven repo, http://repo1.maven.org/maven2/, but the error persists.
Log4j is such a popular library and used by so many frameworks. So it must be transitively injected by maven from any other dependent jar and hence it is available for you in your classpath in eclipse.
You can generate maven dependency tree using plugin.
I just installed m2e (the Maven Eclipse plugin) and created a new Maven Project with a Quickstart archetype. I then went to the official Maven repo to pull down GWT 2.5.1's dependencies, and see that it wants you to add the following <dependency> element to your project's pom.xml file:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
So, altogether, my pom.xml looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.me.myorg</groupId>
<artifactId>maven-resolver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-resolver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</project>
I am getting the following error:
Missing artifact com.google.gwt:gwt:jar:2.5.1
And furthermore, in Eclipse's Package Explorer, under my project's Maven Dependencies library, nothing is resolving.
What's going on here? Thanks in advance!
Update: the contents of ~/.m2/repository/com/google/gwt/gwt/2.5.1 are as follows:
gwt-2.5.1.jar.lastUpdated gwt-2.5.1.pom.sha1
gwt-2.5.1.pom _maven.repositories
This gwt dependencie it's a parent pom for the gwt project. This means that the repo will only contain the hash and the pom, but not the jar.
You need to use two libraries: gwt-servlet and gwt-user:
I've found this configuration for GWT development (maybe you don't need to put the <scope> as described):
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependencies>
Remove your dependencies and update your pom with these two shown above.
You can also use the gwt-maven-plugin to manage your gwt project and deploy via maven. I've found this information there.
I hope that works!