Unable to create spring-mvc project in STS - spring

I am trying to create a spring mvc project. I am creating a Maven project and then selecting the archetypes as
GroupId : co.ntier
ArtifactId : spring-mvc-archetype
Version: 1.0.2
I am getting this error:
Unable to create project from archetype [co.ntier:spring-mvc-archetype:1.0.2 -> http://maven-repository.com/artifact/co.ntier/spring-mvc-archetype/1.0.2]
The defined artifact is not an archetype

Try cleaning up your .m2\repository\ folder. Don't forget to set your proxy in settings.xml. settings.xml is manually created therefore you need to make your own and set the proxy. Here's a sample template for setting up your proxy inside 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>
<active>true</active>
<protocol>http</protocol>
<host> --your proxy here-- </host>
<port> --your port no here-- </port>
</proxy>
</proxies>
</settings>
When you make a new Maven Project and add a new archetype, use this Repository URL instead: http://repo1.maven.org/maven2/
By the way I'm using Eclipse Luna and it works on my end.

In my case i have only change repository URL. try with this url:http://repo.maven.apache.org/maven2/

Try by deleting /co folder inside m2/repository and then add a new archytype while creating Eclipse project. . use this for Repository URL :http://repo.maven.apache.org/maven2/

Related

How to make maven search for artifacts in local repository

I have a project that worked fine on another pc. And now i'm trying to run it on another pc. There is no acces to proxy. And after any action it says that
couldn't transfer artifact. no route to host
But i have all depandencies in local repository, maven just doesn't want to take it from there. Is there a way to make him take all artifacts from local repo first?
There must be a version difference in the artifacts you have in your local repository and the ones mentioned in pom.xml
Your error : couldn't transfer artifact. no route to host
is because you have'nt added proxy to your pom. eg :
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
-->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>yourpassword</password>
<host>yourhost#host.com</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Add it to the settings.xml file in conf folder of maven and try again

Maven Archetype generate proxy issue, searching for remote catalog

Maven seem to be having a bug related to proxy when fetching archetype from maven's remote catalog.
My computer is behind a proxy server. I am trying to generate a project from maven command line.
D:\test>mvn archetype:generate -DarchetypeArtifactId=scala-archetype-simple -DinteractiveMode=false -DgroupId=com.sparktest -DartifactId=myspark -DarchetypeGroupId=net.alchim31.maven -DarchetypeVersion=1.6 -DarchetypeCatalog=remote -e -X
[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml
[DEBUG] Archetype org.apache.maven.archetypes:scala-archetype-simple:1.6 doesn't exist
org.apache.maven.archetype.downloader.DownloadNotFoundException:
Requested org.apache.maven.archetypes:scala-archetype-simple:jar:1.6 download does not exist.
Below Eclipse Bugs are related, however the issue seems to be with maven rather than Eclipse.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=390183#add_comment
Please note there is no issue working on existing maven project. The dependencies get downloaded without any issue once maven proxy is configured in settings.xml. The issue comes when generating a project using archetype:generate and using maven remote archetype-catalog.
Maven archetype-catelog can be opened in a browser without any issue
http://repo.maven.apache.org/maven2/archetype-catalog.xml
It's seems that scala-archetype-simple archetype with groupId org.apache.maven.archetypes doesn't actually exist.
You should try one of these :
net.alchim31.maven
org.scala-tools.archetypes
I had this exact issue and the following worked for me: have two proxies, one for http and one for https.
<proxy>
<id>my-proxy-http</id>
<active>true</active>
<protocol>http</protocol>
<host>xx.xx.x.xxx</host>
<port>8080</port>
<username>myusername</username>
<password>mypassword</password>
</proxy>
<proxy>
<id>my-proxy-https</id>
<active>true</active>
<protocol>https</protocol>
<host>xx.xx.x.xxx</host>
<port>8080</port>
<username>myusername</username>
<password>mypassword</password>
</proxy>

Not able to create maven project under eclipse mars even after setting the proxy

Hi Everyone ,
I am new to Maven environment . Tried all possibilities of enabling the proxy under settings.xml .But no use. Since the maven is integrated in mars I couldn't find the settings.xml and created my own under .m2 . And also tried with the external maven also .But no results .
Below is my settings.xml .
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hostname</host>
<port>port</port>
<username></username>
<password></password>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
</settings>
The failed request from before has been cached by Maven. You need to run the command with the -U flag to retry. (Or wait until the caching has expired...)

No plugin found for prefix 'install' in the current project

I want to add jdbc oracle to maven repository since it is not in repository, I have to run this command:
mvn install:install-file
-Dfile=D:\Temp\ojdbc6.jar
-DgroupId=com.oracle
-DartifactId=ojdbc6 -
Dversion=11.2.0 -Dpackaging=jar
and run into this error:
[ERROR] No plugin found for prefix 'install' in the current project and in the p
lugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the re
positories [local ({my repository path}), central (https://repo.maven.
apache.org/maven2)]
any help would be appropriated.
I recently got the same error and I tried this command. It worked.
export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
I have faced the same issue, there is a two-step process to resolve this issue:
Configure Maven Proxy Configuration
Open Maven configuration file:
For Linux: ${user.home}/.m2/settings.xml
For Windows: C:\users\username\.m2\settings.xml
If you could find the file open it and search for <proxies></proxies> the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags <settings></settings>
Add the proxy configurations as below:
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from
https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.
Now you are ready to use Maven with your programs.
Try adding this to your Maven configuration file:
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
It should install Oracle JDBC to your repository and should install the necessary JARS.
https://www.tech-recipes.com/rx/39256/add-dependencies-to-maven-pom-xml-file/
Add it within the dependencies tag.
Hope it helps!
[ERROR] No plugin found for prefix ‘install’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/amitkumar/.m2/repository), central (https://repo.maven.apache.org/maven2)]
There are 2 steps we need to follow to fix this issues :
Step 1 : Open Maven configuration file: For Linux: ${user.home}/.m2/settings.xml
If you could find the file open it and search for the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags
Add the proxy configurations as below:
<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>
<active>true</active>
<protocol>http</protocol>
<host>www-proxy.us.oracle.com</host>
<port>80</port>
<nonProxyHosts>adc2170275|*.oracle.com|*.oracleads.com|*.us.oracle.com|
*.uk.oracle.com|*.ca.oracle.com|*.oraclecorp.com|
*.oracleportal.com
</nonProxyHosts>
</proxy>
</proxies>
</settings>
Step 2:
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-
2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved

I got the following error message when I tried to create a Maven project in eclipse. Many have posted about proxies in settings.xml file and also flush the .m2 folder forcing it to download a new one. None of this is working for me. I'm at work, with proxy settings active in the internet options.
The error message:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
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.blahhhhhhhhhhhhhhhhh</groupId>
<artifactId>HelloRESTEasy</artifactId>
<version>0.0.1-SNAPSHOT</version>
</project>
settings.xml:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxyserver.company.com</host>
<port>8080</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Try cleaning the local .m2/repository/ folder manually using rm -rf and then re build the project. Worked for me after trying every possible other alternative(reinstalling eclipse, pointing to the correct maven version in eclipse, proxy settings etc)
I was able to solve the same problem with different solution.
The solution that worked for me was to Right click project "pom.xml" in eclipse and select "Maven Install".
I solved it now. However it only is solved in Netbeans. Not sure why eclipse still won't take the settings.xml that is changed. The solution is however to remove/comment the User/Password param in settings.xml
Before:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxyserver.company.com</host>
<port>8080</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
After:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<host>proxyserver.company.com</host>
<port>8080</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Mainly this occurs during Eclipse upgrade.
I Solved using:
-> Right Click Project-> Maven->Update Project-> Select all (checkbox)
Old or out-dated, projects got refreshed with the updated jar files, and the required plugins. No more errors were visible.
For me, this problem occurs in Eclipse when the Maven installation is not well configured. By default the Maven installation is embedded in Eclipse. The .settings.xml file is set wherever the Eclipse installation points.
In my case this file was not auto-generated. I choose my own Maven installation - an external one. But if you don't explicitly choose where settings.xml is then Eclipse tries to get this file from the path set in the embedded installation. If the file is not autogenerated you have to choose the correct location.
Go to windows/preferences/Maven/Installation/user settings and choose the correct location of your settings.xml.
I also faced the above error. I used Eclipse.
After followed the below solution, it works fine for me.
Solution is,
Right click project "pom.xml" in eclipse and select Maven Install.
Right click on the project -> Maven -> Update Project.
Refresh
Right click project "pom.xml" in eclipse and select Maven Install.
Right click on the Project -> Maven -> Update Project.
Then Refresh.
I have had this issue and I resolved it by following the next step:
1- Close Eclipse.
2- Go to user directory and delete the .m2 directory.
3- Open Elipse.
4- Right click on the project -> Run as -> maven install
I have had this issue, and removing the .m2/repository/ has not solved it in my case. Seems that eclipse is unable to download the maven-plugin or dependency needed. Therefore you need to install it yourself.
I have finally solved it downloading both jar and pom files from the Maven Repository and installing it using the command (better than copying to the folder directly):
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>
(In my case: mvn install:install-file -Dfile=maven-war-plugin-2.2.pom -DpomFile=maven-war-plugin-2.2.pom)
In my case the error was: CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 ....
With eclipse luna from console in the pom.xml folder
mvn clean
mvn install
With Juno I had to had this to my pom.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
And then
mvn install
And then from eclipse right click>maven>update project
* Once the plugin is donwloaded you can remove the plugin from your pom.xml
Jotting down some steps which help:
Writing answer from eclipse perspective as base logic will remain the same whether done by Intellij or command line
Rt click your project -> Maven -> Update project -> Select Force update -> Click OK
Under properties tag , add :
> <maven.compiler.source>1.8</maven.compiler.source>
> <maven.compiler.target>1.8</maven.compiler.target>
In some instance , you will start seeing error as we tried force update , saying , failure to transfer X dependency from Y path , resolutions will not be reattempted , bla bla bla
**In such case quickly fix it by cd to .m2/repository folder and run following command :
for /r %i in (*.lastUpdated) do del %i**
I also had the same problem. I used next way:
1.Added settings.xml file (~/.m2/settings.xml) with next content
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>qq-proxya</host>
<port>8080</port>
<username>user</username>
<password>passw</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
3. Using cmd go to folder with my project and wrote mvn clean and after that mvn install !
After that updated project in the Eclipse(Alt + F5) or right click on project -> Maven -> Update project
P.S. after that, when I add new dependency to my project I have to compile project using cmd(mvn compile). Because if I do it using eclipse plugin, I get error connecting with proxy connection.
I had this error, I follwed below three steps to solve,
1). check proxy settings in settings.xml refer,
2). .m2 diretory to release cached files causing problems
3) Point your eclipse to correct JDK installation.
Refer No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? to know how
I also faced same problem... I follow the following steps...u can try it
1. Right click on maven project
2. Take cursor in Maven
3. Click on Update Maven project or (alt+F5).
it will take some time then most probably problem will solved..
There could be multiple reasons, i fixed with following steps:
delete .m2 folder and re launch eclipse. (Find m2 folder in
windows: c:\Users\Your_User_Name\ .m2
or to search in Mac : ~/.m2
make sure settings.xml is configured as #JustinBieber mentioned.
provide settings.xml path in eclipse (windows->preferences->maven->user settings) User Settings must locate settings.xml file.
save changes and relaunch the eclipse..!! it should work.
Excellent i got solution:
Just clearing (.m2) complete folder and starting a new maven project problem solved for me.
Note:: .m2 folder located in os installed disk only.
If you want the exact location, check in Eclipse:
Eclipse-->window-->preferences-->maven-->user settings
There local repository path is for .m2
Delete entire .m2 folder and restart your eclipse.
I had same issue while creating new spring project in eclipse using Maven.
The main reason for this issue is that the proxy settings was not there.
I used the following approach to reslove it:
1) create settings.xml with the below content
<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">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>Your proxy</host>
<port>Your port</port>
</proxy>
</proxies>
<profiles/>
<activeProfiles/>
</settings>
2) Save the settings.xml file under local C:\Users\<<your user account>>\.m2
3) Then Right click project pom.XML in eclipse and select "Update Project". It always give precedence to settings.XML
I have summarised what I did for my issue.
1) Delete .m2 folder.
2) Change the apache-maven-3.5.4\conf\settings.xml as follow
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<host>proxyserver.company.com</host> --> Please change it according to your proxy
<port>8080</port> -->Please change it accordingly
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
3) Try again in cmd. It will work.
4) For eclipse, delete the existing maven project and go to
window ->prefernces -> maven -> user settings -> browse -> configure this path apache-maven-3.5.4\conf\settings.xml
5) Delete .m2 folder.
6) Restart the eclipse and try creating new maven project.
These steps worked for me.
Maybe your network is slow, so that jar isn't downloaded completely.
There are two methods:
a. find your .m2 folder, you can find some path like this 'org/apache/maven/plugins/maven-resources-plugin', you need only delete this foldler 'maven-resources-plugin', because others are downloaded well.
Then maven build your project.
If other problem occures, repeat this process again.
b. you can change a more quick maven source.
Firstly, you should find maven's settings file(window ->prefernces -> maven -> user settings). If it is empty, you can create a new one (any path, for example, .m2/settings).
Secondly, add sth like this (From https://blog.csdn.net/liangyihuai/article/details/57406870). This example uses aliyun's maven.
<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">
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
Thirdly, maven build again. (before this, you should delete your .m2 folder's files)
Force update works for me.
Select the force update option as per image in update maven project.
run:
mvn -U dependency:go-offline
It works for me.

Resources