Spring STS spring boot project maven pom error - spring

Hello I am trying to learn spring boot. I have installed Spring STS
Spring Tool Suite
Version: 3.6.4.RELEASE
Build Id: 201503100339
Platform: Eclipse Luna SR1 (4.4.2)
Java 1.7.
I am trying to create a spring starter project. After I do it with the sts I get the project generated but the Maven pom contains errors.
It always says : Project build error:
Project build error: Non-resolvable import POM: Failure to transfer org.springframework:spring-framework-bom:pom:4.1.6.RELEASE from 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:spring-framework-bom:pom:4.1.6.RELEASE from/to central repo.maven.apache.org/maven2): The operation was cancelled.
Failure to transfer org.springframework:spring-framework-bom:pom:4.1.6.RELEASE from //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:spring-framework-bom:pom:4.1.6.RELEASE from/to central repo.maven.apache.org/maven2): The operation was cancelled.
Project build error: Non-resolvable import POM: Failure to transfer org.springframework.security:spring-security-bom:pom:3.2.7.RELEASE from 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.security:spring-security-bom:pom:3.2.7.RELEASE from/to central ( repo.maven.apache.org/maven2): The operation was cancelled.
The POM is automatically generated when I create a spring starter project and it always generates that error.
I understand that there is something wrong the the spring files but I don't know how to solve that problem.
Can someone here give me please an advice how to solve this.
Thanks.
Best regeards.
Khelvan

I was getting the same issue while importing maven project from spring initialzr.
Spring Tool Suite 4 Version: 4.1.0.RELEASE
Just add below lines in pom.xml file:-
<properties>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Happy Coding ;

I had the same problem, using NetBeans 8.1, Maven 3.0.1, and Spring MVC versions 4.0.1 and 4.2.5.
The first solution I found on the web was to update Maven to version 3.3.9, which did not solve my problem. However, with more search I found a useful link. There it explains for including Maven's "bill of materials" (BOM) dependency you can use:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
Before I was missing <type> and <scope> tags in the auto-generated code. After adding them the problem was solved.
Since I am not sure if updating Maven also helped or not, you might also try that.

Check the version of the bom you are using. When I changed mine to 4.3.5.RELEASE, the error went away

Related

Plugin .url=jdbc:oracle:thin or one of its dependencies could not be resolved - Spring Boot liquibase

I'm currently working in my company developing an API in Spring Boot with an Oracle database, the problem is that we use liquibase to create the database, and when I try to use the command:
mvn liquibase:update -Dliquibase.url="jdbc:oracle:thin:#..." -Dliquibase.username="xxx" -Dliquibase.password="xxx" -Dinterface-user="xxx" -Dtablespace-tablas="xxx" -Dtablespace-indices="xxx" -Dstorage-tablas="xxx" -Dstorage-indices="xxx"
It returns me this error:
Plugin .url=jdbc:oracle:thin or one of its dependencies could not be resolved: Failure to find .url=jdbc:oracle:jar:thin in https://maven.oracle
.com was cached in the local repository, resolution will not be reattempted until the update interval of maven.oracle.com has elapsed or updates are for
ced -> [Help 1]
I think it is related with the dependency ojdbc8 from oracle but I can't figure out how to make it work.
I know that all the credentials for the database and everything are correct as I can totally use them to connect to the database with a db manager.
Here is my dependency in pom.xml:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3</version>
</dependency>
Right now I've tried these things:
Downloading the dependency from maven repo (https://mvnrepository.com/artifact/com.oracle.ojdbc/ojdbc8/19.3.0.0) and installing it locally using the command: mvn install:install-file -Dfile=./ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=19.3 -Dpackaging=jar.
This supposedly installed the dependency locally, but still does not work.
Adding the oracle server to the dependency repos in maven config, following this oracle guide
(https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9016)
With this second change I manage to get a different error:
Plugin .url=jdbc:oracle:thin or one of its dependencies could not be resolved: Could not find artifact .url=jdbc:oracle:jar:thin in maven.oracle
.com (https://maven.oracle.com) -> [Help 1]
Could you help me find what am I doing wrong or something that I might be missing? Thanks!
You need to use the follow GAV for downloading the JDBC driver from central maven. Refer to Maven guide for more details
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
In the end, the main problem was that I was using the embedded console of IntelliJ and It wasn't working that way, I switched to cmd and it worked...

Maven Build Not Finding Oracle

I'm switching a maven project's db from MySQL to Oracle. I have this dependency in my pom.xml:
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
But IntelliJ's maven view shows red squigglies on that dependency and mvn clean install gives me:
Could not resolve dependencies for project com.example:polls:jar:0.0.1-SNAPSHOT: Failure to find com.oracle:ojdbc6:jar:11.2.0.1.0 in 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 -> [Help 1]
So per this advice, I did a force (mvn clean install -U). But that gives me:
Downloading from central: https://repo.maven.apache.org/maven2/com/oracle/ojdbc6/11.2.0.1.0/ojdbc6-11.2.0.1.0.pom
[WARNING] The POM for com.oracle:ojdbc6:jar:11.2.0.1.0 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/com/oracle/ojdbc6/11.2.0.1.0/ojdbc6-11.2.0.1.0.jar
... even though my .m2 does contain that dependency:
So why does my project not build? Is there some reason Oracle jars are not accessible via maven central?
It turns out Oracle JDBC drivers need to be obtained from the "Oracle Maven Repository". There's lots of guidance on that, which I guess I missed at first. They can also be downloaded directly.

How to define parent-version in maven as property?

I'm using the following dependency as parent in my maven pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.6.RELEASE</version>
</parent>
If I define the version as property <version>${spring-boot.version}</version> I'm getting the following error:
Project build error: Non-resolvable parent POM: Failure to transfer
org.springframework.boot:spring-boot-starter-parent:pom:${spring-boot.version}
from http://repo.spring.io/milestone was cached in the local
repository, resolution will not be reattempted until the update
interval of spring-milestones has elapsed or updates are forced.
Original error: Could not transfer artifact
org.springframework.boot:spring-boot-starter-parent:pom:${spring-boot.version}
from/to spring-milestones (http://repo.spring.io/milestone): Illegal
character in path at index 85:
http://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/${spring-boot.version}/spring-boot-starter-parent-${spring-boot.version}.pom
and 'parent.relativePath' points at wrong local POM
So is it not possible to define the parent version as maven property?
Try updating Maven to 3.2.3.
Check these release notes:
Maven 3.2.1
Maven 3.2.2
There was some work done this front in the latest versions of Maven and it should be possible to do it with version 3.2.1 (at least), but if you're upgrading Maven anyway, go with the latest.

Can't download snapshot artifacts when version is specified by range

In POM could be specified wanted range of artifact version (which in next step will be downloaded by maven-dependency-plugin:copy-dependencies):
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>hibi-test</artifactId>
<version>[0.1.4-SNAPSHOT,0.2.0)</version>
</dependency>
Problem is that hibi-test has NO releases on my Nexus, - only few SNAPSHOTS (locked timestamp snapshots). I've checked this POM on artifacts which have both releases and snapshots and it worked good, but in that case I've got only:
[ERROR] Failed to execute goal on project Test: Could not resolve dependencies for project my.group:Test:pom:0.0.1-SNAPSHOT: Could not find artifact my.group:hibi-test:jar:0.1.4
Snapshot repository in POM is defined.
I've tried various combination of range, enabling snapshots and versions:unlock-snapshot, but it didn't work. When I passed only 0.1.4-SNAPSHOT artifact hibi-test-0.1.4-SNAPSHOT.jar was downloaded correctly.
What I need here? :)
is 0.2.0 the latest version?
Maybe you should try to change your range of versions.
Try this:
<version> [0.1.4,0.2.0) </version>

maven dependency not downloading

I'm new to maven. I'm getting the following error, which I don't understand. Can you please help me to understand how to fix it ?
The following artifacts could not be resolved: org.springframework:org.springframework.core:jar:3.0.5.RELEASE, org.springframework:org.springframework.asm:jar:3.0.5.RELEASE: Failure to find org.springframework:org.springframework.core:jar:3.0.5.RELEASE 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]
It would be more helpful if you provide your pom file with the question, but judging from a stacktrace it seems that dependency is not declared correctly. Specifically, correct artifact name for Spring is "spring-core" and not "org.springframework.core", So in your pom.xml file you should have:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
You can find a correct dependency definition at public Maven Repo search engines (like http://mvnrepository.com or http://search.maven.org). Here is the the link to Spring Core artifact: http://mvnrepository.com/artifact/org.springframework/spring-core/3.0.5.RELEASE
Btw, the error that you see is in following format:
<groupId>:<artifactId>:<packaging>:<version>
Try running your command with the -U option. Here is more information.
Yeah looks like your pom dependancy aren't marked correctly. Googling sample Spring MVC app and lookin sample pom will be helpful.

Resources