How to configure maven to use different artifact? - java

I m new to Spring framework. Need a help.
When I create a simple Spring Starter Project using STS (Type : maven, Dependency: Spring Web), it throws an error on POM.xml saying "Project build error: Non-resolvable parent POM..."
This looks like a firewall issue that maven repositories cannot be downloaded from internet in my network. But I have a artifactory where my network can access and download
all required jars from here. Something like: http://artifactory.mycompany.com/artifactory/spring-framework which has a username/password also.
So how do I tell maven to download dependencies from this repository instead of going outside and get it. Can anyone help here.
Thank you,

Related

How to resolve custom created dependencies for springboot project in Jenkins?

I have built a custom SDK dependency on my spring-boot project. The project is built without any issue locally once I install dependency which is then cached in .m2.
Now, when I try to build the project in Jenkins running in the server(AWS EC2) I get Could not resolve dependencies for project <project_name>:war:0.0.1-SNAPSHOT: Failure to find <dependency_name>:0.0.1 error.
My pom.xml looks like
<dependency>
<groupId>com.mysdk</groupId>
<artifactId>my-sdk</artifactId>
<version>0.0.1</version>
</dependency>
The issue here is because the dependency is not found when Jenkins builds the project. Can someone help me with how to install this dependency in Jenkins or how to resolve this kind of issue?
actually you could have an artifact repository, so the jenkins can reach your own artifacts, something like Artifactory https://jfrog.com/open-source/, for example.
If you don't want to have your own server, you should create the my-sdk pipeline in Jenkins, when this pipeline intall the artifact, it will be then available for other Jenkins pipeline.

Unknown small library (ex. webhdfs-java-client) in maven not found

I am trying to implement a little service in Scala using Maven to manage dependencies and I would like to add webhdfs-java-client that I have found at https://github.com/wdavidw/webhdfs-java-client
I have added to pom.xml following code:
<dependency>
<groupId>org.zxs</groupId>
<artifactId>webhdfs-java-client</artifactId>
<version>0.0.0</version>
</dependency>
It does not work, as I have expected. Does anyone could give me an advice if there exists some catalog of maven repositories (something like pip for Python)? And what can I possibly do if I'll not find this library in the catalog? Is it possible to somehow add it to maven manually?
In maven world you can install this dependency locally and resolution will be done via local cache (the one that usually resides in ~/.m2). Steps are as simple as mvn clean install in that repo. Having said this, it wouldn't resolve problem for your users (transitive dependencies, you know), which is why you likely need to publish that dependency somewhere (or ask library author whether it's published somewhere).
SBT, which is scala's de-facto build tool allows you to depend on other sbt flavored projects simply by referencing their git repository, but sadly, maven has no such feature.

Maven repository's issue in Intellij IDEA

I tried all the suggested solutions which found on Stackoverflow but didn't solve the issue with Maven repositories in Intellij IDEA. The problem is that I can't find needed jars in local repository, even if I update it. Central repository is impossible to be updated. Just for example: I use in web-app servlet api (jar is found in local repo but the version is 2.5), jstl and jdbc. If I don't create Maven project I just add all the external libraries to the project manually. But in the case of Maven-project I do not add nothing but try to create dependency through Alt + Ins when writing the class. Result - there are not needed jars in local repository.
What I tried:
1.Installed/deleted a couple of versions of Maven (The current is 3.2.2)
2.Defined local repository in settings.xml (the tag missed by default)
3.Updated local repository
4.Added dependency manually in pom.xml but IDEA didn't define it
Moreover, when I created a first Maven-project in IDEA according to web-app archetype it didn't have needed folders structure but started donloading the number of jars. Current version of IDEA is 13.0. If somebody faced such problem please help me to eliminate it.
But in the case of Maven-project I do not add nothing but try to
create dependency through Alt + Ins when writing the class. Result -
there are not needed jars in local repository
You actually have to perform an maven install, this downloads the jars from whereever to your local repository. Just writing the depenecy in pom, doesn't actually download them.
This is how maven works, nothing to do with intellij.

The dependency is missing from repository (error 404)

I'm trying to use the reflections-maven plugin in a project.
However, Maven refuses to compile the project because the following dependency is missing:
<groupId>org.jfrog.jade.plugins.common</groupId>
<artifactId>jade-plugin-common</artifactId>
<version>1.3.8</version>
I checked on the Maven central repository. The dependency is missing there (error 404).
How can I use reflections-maven without this dependency ?
NOTA:
The rules in my company disallow the use of custom repositories directly in pom.xml.
The internal Nexus MUST be used.
Since your requirements\limitations seem to be:
not available in global nexus
can't be added to your internal nexus
don't want to add it to your lib folder
The only remaining option seems to be for you to install it to your local maven repository as described here: http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html
of course this will present issues on your build server and other teammembers will have to do the same, but I can't think of another solution given the limitations.

Failure with Maven Android : The POM for com.google.android.gms:google-play-services:jar:13.0.0 is missing, no dependency information available

This is the error that I am getting with my current Maven Android Project.
The POM for com.google.android.gms:google-play-services:jar:13.0.0 is missing, no dependency information available
I have tried reinstalling google play services from SDK Manager and running mnv clean install still it does not work.
Any idea how to resolve this.
you need to make sure maven can access the repository the artifact can be found in. For example maven central http://search.maven.org/ does not contain the that artifact.
I would expect a settings.xml or a pom.xml to contain some section in that define where to look for this.
if you can execute maven commands try: mvn help:effective-settings
and as well: mvn help:effective-pom
that should reveal some repositories.
Another issue may be that you need to configure a proxy server for maven if you are behind one.
Is the message a warning or an error? Because it is also common that some artifacts do not have a pom.xml. So if it is a warning but everything else works just ignore it :)

Categories