you can set 'includeSystemScope' to true.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
Answer from allen on Stack Overflowyou can set 'includeSystemScope' to true.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
You could install the sqljdbc41.jar in your local repository :
mvn install:install-file -Dfile=path/to/sqljdbc41.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc41 -Dversion=4.1 -Dpackaging=jar
And then declare the dependency as a standard dependency :
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc41</artifactId>
<version>4.1</version>
</dependency>
If you use a remote artifact repository (nexus, archiva...) you also need to deploy the artifact on this repository. You can find more here : https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
Videos
May be that could help
Copy <dependency>
<artifactId>com.google</artifactId>
<groupId>Ab</groupId>
<version>0.0.4.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Ab.jar</systemPath>
</dependency>
This way you can add any jar file as a maven dependency.
install your external jar using
Copymvn install:install-file
then provide it as maven dependency
Copy<dependency>
<artifactId>your-custom-jar</artifactId>
<groupId>group.id</groupId>
<version>0.0.1</version>
</dependency>
and spring will package it in final executable jar
for more details on installing custom jar refer this
Firstly you can put this code into pom file which project do you want to inject to another
For example this is DAO ' s pom file
<modelVersion>4.0.0</modelVersion>
<groupId>tr.com.project</groupId>
<artifactId>project-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<application.module.version>0.0.1-SNAPSHOT</application.module.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
And you can access into another project to this DAO You must put this code another project' pom
<dependency>
<groupId>tr.com.project</groupId>
<artifactId>project.dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
You could install the project of the external JAR using maven:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
or if the jar was built using maven then this already would be enough:
mvn install:install-file -Dfile=<path-to-file>
This project then will simply be available in your maven repository and you can include it as you do with any other maven dependency.
Hi for this question that you have asked
so how we can create a common library folder so that all spring boot application shares the same dependencies from one location
In pom.xml add maven-dependency-plugin with goal as copy-dependencies and under this you can set the output directory for the common library folder
Example
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Now you can use the below, to create two jar, one jar with all dependencies(named as appname-exec.jar) included, another jar with only class files (appname.jar)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
Now you can use the jar only with class files (appname.jar), because the size will be much lower since it has no dependencies included.
There is one last step needs to be configured in order to work with the jar (appname.jar), is to add the class path entry that is the common location jar and to add your main class name inside tag.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Now you can put these three together in you pom.xml under build section as per you project strucure.
You can use spring-boot-thin-launcher to build executable and thin Spring Boot jar. It is available for both maven and gradle.
Maven:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>1.0.28.BUILD-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Gradle:
plugins {
//other plugins goes here ...
id 'org.springframework.boot.experimental.thin-launcher' version '1.0.28.BUILD-SNAPSHOT'
}
You can run Spring Boot thin JAR by command
java -jar my-app-1.0.jar --thin.root=path/to/dependency/jars
You can have look at:
- Official Plugin Page: https://github.com/spring-projects-experimental/spring-boot-thin-launcher
- Tutorial: https://www.baeldung.com/spring-boot-thin-jar
For including a jar from a path into your Spring boot classpath see
External library folder for Spring Boot.
This means that you can safely manage your dependency in your pom by a repo (avoiding sytemPath dependencies).
With SpringBoot project using Maven build tool, you can use:
mvn install:install-file "-DgroupId=org.apache.poi" "-DartifactId=poi-ooxml" "-Dpackaging=jar" "-Dfile={your_path_to_jar_file}" "-Dversion=1.1.0"
Good luck,