I am going through this guide:
https://spring.io/guides/gs/rest-service/
I use Maven for building, so I've fetched the pom.xml linked in the official Spring guide:
https://github.com/spring-guides/gs-rest-service/blob/master/initial/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>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-build</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</project>
I get the following error when running mvn install
[ERROR] Error resolving version for plugin
org.springframework.boot:spring-boot-maven-build' from the
repositories [local (C:\Users\Laszlo_Szucs.m2\repository),
spring-snapshots (repo.spring.io/libs-snapshot), central
repo.maven.apache.org/maven2)]: Plugin not found in any plugin
repository -> [Help 1]
How do I know which version to provide in the pom.xml for this?
Check whether http://repo.spring.io/libs-snapshot is in pom.xml. If not, Add http://repo.spring.io/libs-snapshot to maven repository.
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
And upgrade the maven to 3.0.5 above.
In my case, removing the ~/.m2/repository/org/springframework/boot folder and then cleaning the project resolved the issue. After this issue, I also faced another issue in which STS complained that my maven project was not updated. However, right clicking on the issues in the Markers area and selecting Quick Fix popped up a window which prompted me to update the maven projects. Selecting the projects and clicking the update button in this window resolved the issue.
I specified d goals as "spring-boot:run" (without quote) it works for me
procedure: right click on myproject>run as >run configurations >click on mavenbuild>goals(specify goal name)>run
Related
I attempt to implement the example from here, but upon the Maven dependencies installation I can't find jar file amongst downloaded dependencies.
My pom.xml looks like this:
<?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>
<!-- This is often your domain name (reversed.) -->
<groupId>com.abc</groupId>
<!-- The name of this project (actually, the name of the artifact, which is the thing that this project produces. A jar in this case.) -->
<artifactId>javaparser-maven-sample</artifactId>
<!-- The version of this project. SNAPSHOT means "we're still working on it" -->
<version>1.0-SNAPSHOT</version>
<properties>
<!-- Tell Maven we want to use Java 8 -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Tell Maven to treat all source files as UTF-8 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>2.5.7</geotools.version>
</properties>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository> <!--Add the snapshot repository here-->
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>opengeo</id>
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</repository>
</repositories>
<dependencies>
<!-- Here are all your dependencies. Currently only one. These are automatically downloaded from https://mvnrepository.com/ -->
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mil.nga.geopackage/geopackage -->
<dependency>
<groupId>mil.nga.geopackage</groupId>
<artifactId>geopackage</artifactId>
<version>3.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-api -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-api</artifactId>
<version>20.5</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-geometry -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geometry</artifactId>
<version>2.5-M2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-referencing -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>17.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.locationtech.jts.io/jts-io-common -->
<dependency>
<groupId>org.locationtech.jts.io</groupId>
<artifactId>jts-io-common</artifactId>
<version>1.16.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.opengis/geoapi -->
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-jts-wrapper -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-jts-wrapper</artifactId>
<version>17.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>17.0</version>
</dependency>
</dependencies>
<!-- This blob of configuration tells Maven to make the jar executable. You can run it with:
mvn clean package
java -jar target/javaparser-maven-sample-1.0-SNAPSHOT-shaded.jar
-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.abc.conversion.LogicPositivizer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am able to download all the jars except geotools related jars. When I clean and run the project, in the .m2 folder I am not able to see the geotool related jars. Even in the maven repository I am not able to download the jar file.
Maven repo
Is there any alternative way to proceed?
The repository run by Boundless has been replaced by one hosted by OSGeo. The OSGeo webdav repo was merged into the new OSGeo repo. Details are here (https://docs.geotools.org/latest/userguide/tutorial/quickstart/maven.html)
Replace this block
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository> <!--Add the snapshot repository here-->
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>opengeo</id>
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</repository>
with
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
If you paste the Open Source Geospatial Foundation Repository URL in your web browser and hit enter it will return 404 Not Found error. This happens when Maven attempts to connect to that resource to fetch dependency for you but it's no longer available. However, if you pay close attention to Maven Repo link, there is a note:
Note: this artefact is located at Boundless repository (https://repo.boundlessgeo.com/main/)
Try to replace http://download.osgeo.org/webdav/geotools/ with a given in the note URL and run mvn clean install
Please let me know if that worked for you.
I am new to the spring boot framework and I'm trying to import the Maven libraries, but I keep getting an error with my pom.xml. Please Help!
Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from https://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. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
Dependency 'org.springframework.boot:spring-boot-starter-web:' not found less... (Ctrl+F1)
Inspection info: Inspects a Maven model for resolution problems.
Plugin 'org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE' not found less... (Ctrl+F1)
Inspection info: Inspects a Maven model for resolution problems.
Here is my pom.xml below:
<?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.cierra</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.4.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
This maybe due to the reason that it is not able to connect and transfer dependencies specified in pom.xml file. The details where it is trying to connect must be mentioned in your settings.xml under .m2 folder
Try adding the pluginRepositories in your pom.xml file:
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
try adding following repository elements inside repositories element in your pom.xml
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
If this set well, change your updatePolicy settings.
<repository>
<id>myRepo</id>
<name>My Repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
Refer question.
The problem was I was behind a proxy that was blocking my pom.xml from running properly. After using a VPN to run the application, it works fine now.
Change Your Maven Version Ad Check Again.
Install Maven and Then Go to File/setting/build,execution,.../build Tools/maven
And Change Maven Home Directory to Your Install Maven Directory
I am using Maven build to build my project(using Eclipse IDE).
I have put jdk1.8 as default jdk, but still, I am getting an error as the source is 1.6.
Is there a configuration problem I am missing out? Please let me know?
(use -source 8 or higher to enable lambda expressions)
1. "clean install" as goals in "Run Configurations" in Eclipse.
2.pom.xml file
<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.mastercard.ayman</groupId>
<artifactId>Spring_MVC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-libs-release</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Compiler is JavaSE-1.8
Either set the maven-compiler-plugin as #Horst says or set the maven.compiler.source and maven.compiler.target properties like this.
<project ...>
...
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
...
</dependencies>
<build>
...
</build>
</project>
This is something I have dealt with too many times.
Could you post the following things as an answer?
Your current build command/query.
Your pom.xml code.
Your compiler version.
With these file(s) I could help you further to resolve your problem!
Setting the JDK in eclipse is only half the story, as maven manages the compiler itself.
Try adding the maven compiler plugin to you build configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
My pom doesn't download this dependancy splunk:jar:1.6.0.0 though the remote repositories does host this jar.
Also, my IDE doesn't have internet/proxy issues while downloading other maven repositories.
Below is the mvn pom :
<?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.jl</groupId>
<artifactId>p1p2checklist</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>p1p2checklist</name>
<description>P1P2 project for John Lewis Partnership</description>
<dependencies>
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.6.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>splunk-artifactory</id>
<name>Splunk Releases</name>
<url>http://splunk.artifactoryonline.com/splunk/ext-releases-local</url>
</repository>
</repositories>
</project>
The remote repository url (link) mentioned in above pom does contain the jar, however I'm not sure why the jar isn't downloaded.
Any help would be much appreciated.
Many Thanks in advance.
You are missing dependencies around your dependency tag.
<dependencies>
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.6.0.0</version>
</dependency>
</dependencies>
This error encountered because splunk:jar:1.6.0.0 not found at http://splunk.artifactoryonline.com/splunk/ext-releases-local so please update it to https://splunk.artifactoryonline.com/artifactory/ext-releases-local at nifi-splunk-bundle's POM.xml file.
<repository>
<id>splunk</id>
<name>Splunk Artifactory</name>
<url>http://splunk.artifactoryonline.com/artifactory/ext-releases-local/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
I am trying to publish my plugin to the pluginrepository on OSS-SonaType. They have already provisioned my namespace for both snapshots and full releases. I am struggling to make my first initial commit to the repo. I can't seem to find the right Maven Configuration to push the plugin to the repo rather than trying to update the repo. Below find my pom.xml, and maven configuration code. Any help would be greatly appreciated!
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.companynamehere.dmweb</groupId>
<artifactId>DMWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DMWeb</name>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>OSS-Repo</id>
<name>oss-repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
Maven Config:
Goals: com.companynamehere:DMWeb:validate
Error:
Error resolving version for plugin 'com.companynamehere:DMWeb' from the repositories [local (C:\Users\kylec\.m2\repository), OSS-Repo (https://oss.sonatype.org/content/repositories/snapshots), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]