The team members were addicted to the site, and even if I tried to find out how to do it, it didn't work out, so I'll leave a note of what I did a little differently.
It's not particularly difficult, but when it fits, it fits.
Java8 Maven3 Spring boot 2.0.2.RELEASE
Include external jar in jar created with ./mvnw clean package
This time, you only have to include it in the package, so there is no particular implementation.
pom.xml We will set the external jar in pom.xml without implementation.
dependencies It can't be helped if it is only in the package, so I will add the information of the jar that I want to add this time to the dependency. If you update after adding it, development on Eclipse should not be a problem.
I'm not so familiar with maven variable expansion, but when setting a folder, $ {project.basedir}
and $ {basedir} are often caught in the search to specify the reference folder. However, it seems that the former points to the project directory and the latter points to the pom.xml directory. For the time being, when I looked at the maven page, I often saw the former, so this time I will use
$ {project.basedir}`.
Note that it seems that version
and the last version of the jar name must match (an error will occur in Eclipse), so please match that.
pom.xml
<dependency>
<groupId>com.tasogarei</groupId>
<artifactId>hogehoge</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/hogehoge1.jar</systemPath>
</dependency>
plugins
The setting to mix in the jar is done from the plugin setting.
There is a ʻinclude SystemScope in the
configuration, just make it
true`.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
This time, it is set as $ {project.basedir} /lib/hogehoge1.jar
, so place an appropriate jar.
Anything was fine, so I brought the jar that was in .m2 /
appropriately.
That's all for the settings. Let's try it.
package Make it a jar from the mvnw command.
./mvnw clean package
Now that the jar has been created successfully, let's check the contents of the jar created with jar tf
.
When I checked, BOOT-INF / lib / hogehoge-1.jar
exists, so I succeeded in including the external jar safely.
$ jar tf jartest-0.0.1-SNAPSHOT.jar | sort
BOOT-INF/
BOOT-INF/classes/
BOOT-INF/classes/application.properties
BOOT-INF/classes/com/
BOOT-INF/classes/com/tasogarei/
BOOT-INF/classes/com/tasogarei/app/
BOOT-INF/classes/com/tasogarei/app/JartestApplication.class
BOOT-INF/lib/
BOOT-INF/lib/hogehoge-1.jar
BOOT-INF/lib/javax.annotation-api-1.3.2.jar
BOOT-INF/lib/jul-to-slf4j-1.7.25.jar
BOOT-INF/lib/log4j-api-2.10.0.jar
BOOT-INF/lib/log4j-to-slf4j-2.10.0.jar
BOOT-INF/lib/logback-classic-1.2.3.jar
BOOT-INF/lib/logback-core-1.2.3.jar
BOOT-INF/lib/slf4j-api-1.7.25.jar
BOOT-INF/lib/snakeyaml-1.19.jar
BOOT-INF/lib/spring-aop-5.0.6.RELEASE.jar
BOOT-INF/lib/spring-beans-5.0.6.RELEASE.jar
BOOT-INF/lib/spring-boot-2.0.2.RELEASE.jar
BOOT-INF/lib/spring-boot-autoconfigure-2.0.2.RELEASE.jar
BOOT-INF/lib/spring-boot-starter-2.0.2.RELEASE.jar
BOOT-INF/lib/spring-boot-starter-logging-2.0.2.RELEASE.jar
BOOT-INF/lib/spring-context-5.0.6.RELEASE.jar
BOOT-INF/lib/spring-core-5.0.6.RELEASE.jar
BOOT-INF/lib/spring-expression-5.0.6.RELEASE.jar
BOOT-INF/lib/spring-jcl-5.0.6.RELEASE.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/maven/
META-INF/maven/com.tasogarei/
META-INF/maven/com.tasogarei/jartest/
META-INF/maven/com.tasogarei/jartest/pom.properties
META-INF/maven/com.tasogarei/jartest/pom.xml
org/
org/springframework/
org/springframework/boot/
org/springframework/boot/loader/
org/springframework/boot/loader/archive/
org/springframework/boot/loader/archive/Archive$Entry.class
org/springframework/boot/loader/archive/Archive$EntryFilter.class
org/springframework/boot/loader/archive/Archive.class
org/springframework/boot/loader/archive/ExplodedArchive$1.class
org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator$EntryComparator.class
org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator.class
org/springframework/boot/loader/archive/ExplodedArchive.class
org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
org/springframework/boot/loader/archive/JarFileArchive.class
org/springframework/boot/loader/data/
org/springframework/boot/loader/data/RandomAccessData.class
org/springframework/boot/loader/data/RandomAccessDataFile$1.class
org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
org/springframework/boot/loader/data/RandomAccessDataFile.class
org/springframework/boot/loader/ExecutableArchiveLauncher.class
org/springframework/boot/loader/jar/
org/springframework/boot/loader/jar/AsciiBytes.class
org/springframework/boot/loader/jar/Bytes.class
org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
org/springframework/boot/loader/jar/CentralDirectoryParser.class
org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
org/springframework/boot/loader/jar/FileHeader.class
org/springframework/boot/loader/jar/Handler.class
org/springframework/boot/loader/jar/JarEntry.class
org/springframework/boot/loader/jar/JarEntryFilter.class
org/springframework/boot/loader/jar/JarFile$1.class
org/springframework/boot/loader/jar/JarFile$2.class
org/springframework/boot/loader/jar/JarFile$JarFileType.class
org/springframework/boot/loader/jar/JarFile.class
org/springframework/boot/loader/jar/JarFileEntries$1.class
org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
org/springframework/boot/loader/jar/JarFileEntries.class
org/springframework/boot/loader/jar/JarURLConnection$1.class
org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
org/springframework/boot/loader/jar/JarURLConnection.class
org/springframework/boot/loader/jar/StringSequence.class
org/springframework/boot/loader/jar/ZipInflaterInputStream.class
org/springframework/boot/loader/JarLauncher.class
org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
org/springframework/boot/loader/LaunchedURLClassLoader.class
org/springframework/boot/loader/Launcher.class
org/springframework/boot/loader/MainMethodRunner.class
org/springframework/boot/loader/PropertiesLauncher$1.class
org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
org/springframework/boot/loader/PropertiesLauncher.class
org/springframework/boot/loader/util/
org/springframework/boot/loader/util/SystemPropertyUtils.class
org/springframework/boot/loader/WarLauncher.class
Recommended Posts