I must say - googled!

I need to add the library SimleCalc-1.0.jar.

pom.xml

<dependency> <groupId>com.homework</groupId> <artifactId>SimpleCalc</artifactId> <version>1.0</version> <systemPath>${basedir}\src\main\resources\SimpleCalc-1.0.jar</systemPath> </dependency> 

If my primo classes are in the main / java / folder, then everything works.
But if the classes of my application, for example, in the main / java / com.myapp / folder, the library does not pull up.

I tried to add the library through

 mvn deploy:deploy-file 

The effect is the same.


Questions:
Why, if the application classes are not in the main / java / custom library folder, do not pull up?
How to add custom libraries to maven correctly?


Whole pom.xml

    2 answers 2

    It should not be main/java/com.myapp/ , but main / java / com / myapp / according to the language specification. To connect the library (jar file) is enough to be in the classpath . For example, you can add it like this:

     java -jar -cp src/main/resources/SimpleCalc-1.0.jar %my_main_class% 

    Add libraries via systemPath - systemPath . I recommend maven-dependency-plugin , which will add dependencies when building. To make the library visible in the IDE you should do:

     mvn install:install-file 

    To do this, you can connect maven-install-plugin

      If you are trying to add your library to the dependency of the maven module, which is not in the maven repository (and you are not going to add it there), then you can create your local repository, even within the project. Put your jar file there and designate the local repository in pom.xml :

       <repositories> <repository> <id>my-maven-repository</id> <name>my-maven-repository</name> <releases> <enabled>true</enabled> <checksumPolicy>ignore</checksumPolicy> </releases> <snapshots> <enabled>true</enabled> </snapshots> <url>file://${project.basedir}/my-repository</url> </repository> <!-- Maven central repository --> <repository> <id>central</id> <name>Maven Repository Switchboard</name> <layout>default</layout> <url>http://repo1.maven.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> 

      In the folder with the project (where there is a file pom.xml ) create a folder named my-repository . Now it only remains right to put your jar . This useful answer will help us in this.