1

I need to create a website using Spring MVC so I'm using STS for this purpose. I'm also using maven as a build tool.

I'm new to java so I'm having a hard time figuring where to keep thing or what directory structure to follow. STS helped me create a Starter Spring project which looks like the following

Project Structure

I have a custom jar file xyz.jar that I need to consume as a service in this website.

Can some please guide me where this file should be kept and how to include it in the build output ?

Storm
  • 4,307
  • 11
  • 40
  • 57
  • http://stackoverflow.com/questions/5692256/maven-best-way-of-linking-custom-external-jar-to-my-project – cool Oct 03 '15 at 06:46

1 Answers1

1

Run below maven command with corresponding parameters it will create a folder inside .m2 folder and add jar there

mvn install:install-file -Dfile=C:\JarLocation\xyz.jar -DgroupId=<Add Group Id for your Jar> -DartifactId=<Add Artifact ID> -Dversion=<Add Version>  -Dpackaging=jar

then in your pom.xml make a entry for this dependency

For example you can check how i achieve it.

mvn install:install-file -Dfile=C:\Users\hariom\JavaEncryptPassword-0.0.1-SNAPSHOT.jar -DgroupId=com.oss.mdf -DartifactId=java.encrypt.password -Dversion=1.0.0 -Dpackaging=jar

and in my pom.xml file i added this entry

   <dependency>
        <groupId>com.oss.mdf</groupId>
        <artifactId>java.encrypt.password</artifactId>
        <version>1.0.0</version>
    </dependency>
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
  • Thanks. I did see this answer in a few posts I searched but I just didn't understand what group id or artifact id I should be giving to a jar that already has its own namespace and is already an artifact 'xyz.jar' (If i'm thinking correctly) – Storm Oct 03 '15 at 06:53
  • Just a quick question, does the groupid, articfactid and version have to be exactly the same as what is in the jar or am I telling maven how to store it by defining these attributes? – Storm Oct 03 '15 at 06:56
  • No it not mandatory see in my case also jar file name is like this `JavaEncryptPassword-0.0.1-SNAPSHOT.jar` but my artifactid,version i made which i like – Subodh Joshi Oct 03 '15 at 06:58