I have a simple java application - maven project in my Netbeans IDE.
After I created Maven Web Application and added first project as a dependency Netbeans shows that everything is OK, and I can use all methods as well.
But in runtime I am getting
java.lang.ClassNotFoundException: com.example.dal.factory.PersistenceDaoFactory
Is it possible to make web project depending on simple java application without creating multimodule java EE application?
Yes, but you need to install your first project locally:
mvn install:install-file \
-Dfile=<path-to-file> \
-DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=jar
Setting up NetBeans to use a project as a dependency isn't the same thing as having a Maven artifact you can use in other Maven projects; for Maven, you need to have it in a Maven repo.
Related
Im working in this intellij java maven project on ubuntu 18.04, i want to run my project but i get this error message:
java: cannot find symbol
symbol: class sdkBaseException
location: package com.amazonaws
These are the libraries that i have installed but for some reason com.amazonaws.SdkClientException is not working when im trying to import with import com.amazonaws.SdkClientException but all the other com.amazonaws.blahblah are working just fine.
I already installed the AWS toolkit plugin, what em i missing? i cant find anything helpfull online.
Im working in this intellij java maven project
If this is a Maven based project you must manage dependencies in Maven pom.xml and not manually through IDE UI.
Add required dependency into the dependencies section of your pom.xml file.
If this is a locally built dependency, then first install it into your local Maven repository:
mvn install:install-file \
-Dfile=<path-to-file> \
-DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<packaging> \
-DgeneratePom=true
You need to follow the import documentation depending on the version of the library you are adding, in this case for version 1.11.1034 use this documentation https://jar-download.com/artifacts/com.amazonaws/aws-java-sdk-core/1.11.1034/documentation.
You have to import all the following dependencies for that version:
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.amazonaws.SdkBaseException
com.amazonaws.AmazonClientException
com.amazonaws.SdkClientException
If you are looking for other versions see: https://jar-download.com/maven-repository-class-search.php?search_box=com.amazonaws.SdkClientException&p=5
Recently I tried to develop an interface for my group. My service runs and works well on my local machine, but when trying to use Maven Compile in IDEA, the compilation fails and tells me it cannot find my JAR package. The JAR package I use is JAVE (Java Audio Video Encoder), which was manually added into my CLASSPATH. I know Maven cannot find JAR package without adding dependency to pom, but I can't find the Maven dependency for JAVE, it seems that they only provide a JAR package for users. JAVE HomePage
So in this case, what should I do if I want to successfully compile my code using Maven? I need to deploy my service in the future, so manually adding JAR package to my CLASSPATH instead of adding dependency to pom is definitely not acceptable.
You can install a maven jar locally using:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
You can install the artefact to either your local or a remote maven repo or you could use it as a system-scoped dependency (see https://stackoverflow.com/a/2177417/9705485 or http://roufid.com/3-ways-to-add-local-jar-to-maven-project/ for examples)
I am using some classes from a github project. I created a maven project and added the dependency from the provided github project, but I need to change some code in those project classes.
I have downloaded and modified the repository but now I have no idea how to import it and use the classes to my existing project.
Any help will be appreciated.
Once you have built your modified github project, you can install it in your local maven repository.
Just use this command:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
If you have built it with a different version, you now just have to reference this new version in your pom.xml file.
I am on proxy network and proxy is preventing maven to connect to central repo
Is there any way to download the maven plugins manually and installing the plugins in local .m2 repo.
Thanks
If you have the jar, you can use :
mvn install:install-file -DgroupId=<your_group_name> \
-DartifactId=<your_artifact_name> \
-Dversion=<version> \
-Dfile=<path_to_your_jar_file> \
-Dpackaging=jar \
-DgeneratePom=true
An example of the same:
mvn install:install-file \
-DgroupId="org.apache.maven.plugins" \
-DartifactId="maven-site-plugin" \
-Dversion="3.7.1" \
-Dfile="D:\Jars\maven-site-plugin-3.7.1.jar" \
-Dpackaging=jar \
-DgeneratePom=true
if you don't have the (plug-in) jar, and it's not a private artefact, you can find the jar and the information in repository website (for example http://mvnrepository.com/ ) or download from your private repository like Nexus or Azure Feeds.
Have a look here if you want to configure a proxy for maven. That way you do not need to download the dependencies in any obscure and unreliable way: Howto configure a proxy for Maven
The simplest way to do this is to use any machine that can connect to central to download all repo you need then copy ./m2 manually to your machine with usage of offline flag every build
if your solution is scalable you will need to install nexus or any maven repository on machine can goes outside and you configure maven to see repo machine. and this is the model solution to that case
To install a jar you can use install:install-file to install any kind of jar. But a maven plugin comes with dependencies so you will have to install them. My suggestion would be to copy a .m2 repo from a machine with access to the internet (for maven).
How to point to a local repository in the maven build process. In that case I want to link directory with custom jars with the compilation and packaging.
Tried following "mvn compile -Dmaven.repo.local=E:\Test\lib" but it doesn't use located jars for the compilation.
Is there way to include repository through maven pom.xml in the way we inject dependencies?
Just install the custom jars into your local repository (usually located under C:..User.m2\repository) via maven-install-plugin:
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
But i would suggest to install a repository manager (like Archiva, Artifactory, Nexus) and install those artifacts there. So you need to do the manual installation work only once and not on every developing machine.
The best way to configure several repositories is via the settings.xml file and not in the pom.xml file.
Exactly pom.xml is for that purpose to maintain dependencies.. you can get more on here
What do you mean by "Local Repository"?
If you mean a local Nexus / Artifactory you can use the Maven sections in your settings.xml
http://maven.apache.org/guides/mini/guide-mirror-settings.html
If you mean the local repository cache (the .m2 dir) that should just work out-of-the-box.