How to run spring project offline mode? - java

I am trying to run a Spring Project, with several dependencies, that I have already downloaded into my local repository, and have also done followings :
Added local repository path in setting.xml in localRepository tag.
Running the project using mvn install -nsu -llr -o , for offline mode.
And I am getting following error :
[ERROR] Failed to execute goal on project file2Json: Could not resolve
dependencies for project
com.nse.file2Json:file2Json:jar:0.0.1-SNAPSHOT: Cannot access central
(http://repo1.maven.org/maven2) in offline mode and the artifact
com.fasterxml.jackson.dataformat:jackson-dataformat-csv:jar:2.8.4 has
not been downloaded from it before. -> [Help 1]
I have the dependency installed, take a look :(
I have following questions :
Why is the project is trying to look into http://repo1.maven.org/maven2 when I am using offline mode ?
How can I run the project offline, by providing the required dependencies at required paths ?
Please help !
thanks in advance.

It says it cannot access Maven Central because you are in offline mode. And it tries to look there, because ´jackson-dataformat-csv` is not in your local repository, so Maven needs to get it from somewhere (and Maven Central is the default repository).
What you need to do is to execute mvn dependency:go-offline before you switch to the offline mode. This will download everything that you need (dependencies, transitive dependencies as well as plugins).

Related

Intellij Maven dependency not resolved while following guide

I am currently trying to follow this guide and every time I try to run the test code I am getting this error:
[ERROR] Failed to execute goal on project MyBot: Could not resolve
dependencies for project org.example:MyBot:jar:1.0-SNAPSHOT:
org.javacord:javacord:jar:3.4.0 was not found in
https://repo.maven.apache.org/maven2 during a previous attempt. This
failure was cached in the local repository and resolution is not
reattempted until the update interval of central has elapsed or
updates are forced -> [Help 1]
pom.xml
Maybe you have to load the dependencies you added to the pom.xml.
in IntelliJ you can right click on your pom.xml chose maven -> reload Project.
This loads all dependencies from pom.xml.
Check the console output for any errors.
Should the answer from Kaspatoo not working for you you can try to add the repository from Javacord to your project.
I figured it out, maven had downloaded the jars for the Dependency but wasn't loading them, I pointed maven to them in the system directory, and its working now

Failed to execute goal on project.. Failed to read artifact descriptor for error in IntellJ

I imported my project and when did a maven clean build was successful, but when maven install is done this Build Failure occurs.
I have my maven in C\maven\maven 3.6 and I have given the settings and repo location of that location to this project.
My Env variables are correctly set up with reference to Java and Maven as well. Please help me on this to get it solved.
it may be because of the proxy ! Check you proxy and test if it's working.

maven linux without download plugins

Im trying to run maven on a linux server that does not have internet connectivity.
I installed maven but when I run "mvn compile" on my java project, it gets stuck trying to download plugins.
How do I get past it? Is there a place to get a full install with all plugins required so it dosent have to download anything?
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.6 has not been downloaded from it before. -> [Help 1]
You can download all jars or import/move them already downloaded from another machine from userHome/.m2 to your ~/.m2 folder, and when you'll try to compile again it'll pull the libs/plugins from m2 folder without trying to download them.
No.
Running Maven does not make sense unless you are connected to a Maven repository.
If you have no internet connection then you need an internal Maven repository, i.e. a Nexus or Artifactory server in your company. Now this server does not only provide the dependencies for you, but also the plugins for Maven to run (of course, it has to get them somewhere from, so it needs some kind of connection to the internet).

Jenkins: build failing because of third party jar : Could not find artifact com.oracle:ojdbc7:jar:12.1.0.1.0

On my windows machine: I have setup jenkins CI to automatically create build.
But every time build is failing because of the third party ojdbc7.jar file.
[ERROR] Failed to execute goal on project abc-cc-onboarding-repository: Could not resolve dependencies for project com.abc.cc:abc-cc-onboarding-repository:jar:1.0-SNAPSHOT: Could not find artifact com.oracle:ojdbc7:jar:12.1.0.1.0 in central (https://repo.maven.apache.org/maven2) -> [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]
When I manually build using: mvn -U clean build, everything works fine.
because I have manually installed ojdbc7.jar in the local repository (.m2)
Something is wrong with the Jenkins integration with maven.
Can anybody suggest on this?
Something is wrong with the Jenkins integration with maven.
No. That's not the problem. Jenkins integration with Maven works just fine.
The problem is that ojdbc7.jar is not in the Maven Central repo ... which is the default place that Maven looks. (Or at least, it is not in Maven Central not with those artifact "coordinates". There are some ojdbc artifacts with different coordinates. YMMV.)
The real problem is that Oracle don't want you to download Oracle JARs from Maven Central. Oracle want you to download from their Maven repo instead.
One solution is to do what you have been doing. Simply add the artifact to your local repo (or Jenkins' local repo for the project). But you are not happy with that.
The other solution is to configure the remote repos that Maven uses.
Here is a page that explains how to configure (stand alone) Maven to include the Oracle repo:
Get Oracle JDBC drivers from the Oracle Maven Repository - NetBeans, Eclipse & Intellij
For the Jenkins case, you need to configure the settings that the Jenkins server uses:
How to manage maven settings.xml on a shared jenkins server?
This lists various ways of doing this.
SOLUTION THAT WORKED FOR ME:
What i found after the analysis and it resolved my problem, hope it will help somebody like me.
Actually jenkins creates a separate repository for separate projects.
like if i have 10 project in my jenkins workspace then it creates 10 repository one for each project (inside the project on top level we can see that).
so now i installed manually ojdbc7.jar inside my jenkins project repo and it solved my problem.
The above error occurs mostly when Jenkins is unable to download the oracle jar.
To sort the above issue
Create the settings.xml and settings-security.xml files in Jenkins through the "Managed files" in the administration home. To do that follow this link - https://wiki.jenkins.io/display/JENKINS/Config+File+Provider+Plugin#ConfigFileProviderPlugin-Howitworks
NB: Ensure to put in your Oracle credentials in these two files. To do that follow this link - https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017
In your jenkins project under configurations in Build Environments include this files under the option Provide Configuration files. As shown below:
Once done build it and it should work.

Cannot find disco.jar dependency for Maven Project

I've just started helping my professor out for his research project and I'm trying to get it set up on my local windows computer. I'm stuck with this error:
Failed to execute goal on project tornado: Could not resolve
dependencies for project tornado:tornado:jar:0.0.1-SNAPSHOT: Failure
to find com.disco:disco:jar:10.2.0 in http://clojars.org/repo was
cached in the local repository, resolution will not be reattempted
until the update interval of clojars.org has elapsed or updates are
forced
Notes:
It's a maven project being run on eclipse.
I've tried multiple ways of adding the disco-2.0.jar file to the build path but I'm not sure if that's what I'm meant to be doing or if it's even the right file, although I haven't found any other disco file within the project directories.
I've tried mvn clean install -U to see if it may just have been a problem with resetting the maven project.
Well the log reads is clear and you could verify it as well:
Failure to find com.disco:disco:jar:10.2.0 in http://clojars.org/repo
If you navigate to the https://clojars.org/repo/com/ there is no disco.jar available there. Hence the failure.
Probably this could be some local jar that might need to be build either locally or required by its owner to be pushed(mvn deploy) to clojars in another case.
Also mvn clean install -U help you fetch the latest of SNAPSHOT, in your case this would fetch the latest tornado:tornado:jar:0.0.1-SNAPSHOT but that fails further sicne it specifies the com.disco:disco:jar:10.2.0 as dependency which is not found anywhere for your build to proceed.
You need to make the disco-2.0.jar available from a Maven repository. If you have a Nexus or Artifactory, upload it there. Alternatively, you can install it into the local repository of your computer using the install:install-file goal.
Furthermore, it is possible to define local directories as additional Maven repositories, see https://stackoverflow.com/a/28762617/927493.

Categories