将外部库.jar添加到Spring boot .jar内部/lib [英] Add external library .jar to Spring boot .jar internal /lib

查看:170
本文介绍了将外部库.jar添加到Spring boot .jar内部/lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外部.jar,它无法使用pom.xml从公共存储库导入,它是sqljdbc41.jar.

I have an external .jar that cannot be imported from public repositories using pom.xml, it's sqljdbc41.jar.

我可以从IDE在本地运行项目,并且一切正常.像这样下载后,我引用了该库:

I can run the project locally from my IDE, and everything will work. I referenced the library after downloading it like so:

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc41</artifactId>
    <version>4.1</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/sqljdbc41.jar</systemPath>
</dependency>

当我运行mvn clean package创建我的.jar文件并尝试运行创建的.jar时,将弹出一个错误,提示SQL Server引用无效.然后,我解压缩了我的.jar文件,并且足够真实,正确下载并添加了pom.xml文件中引用的所有内容,但是我的SQL Server没有.

When I run mvn clean package to create my .jar file and try to run the created .jar, a mistake will pop up, which mentions the SQL Server references are not valid. I then extracted my .jar file and true enough, everything that is referenced in the pom.xml file properly gets downloaded and added, however, my SQL Server does not.

我可以用一种很不客气的方式*,只需将sqljdbc41.jar手动添加到我的/lib文件夹中,然后将其编译为.jar,它就可以工作,但是,这似乎不是最理想的选择.有什么更好的方法?

I can, in a very hacky way* just manually add the sqljdbc41.jar to my /lib folder after it's been compiled as a .jar, and it'll work, however that seems highly unoptimal. What would be a better approach?

*使用Winrar打开.jar文件,转到/lib文件夹,手动选择我的sqljdbc41.jar文件,然后确保选择左下角的No Compression选项,其中Winrar为您提供压缩选项,以防万一由Google发表,没有人回答.

*Opening the .jar file with Winrar, going to the /lib folder, manually selecting my sqljdbc41.jar file, then make sure to select the No Compression option bottom left where Winrar gives you compression options, in case you find this by Google and no one answered.

推荐答案

,您可以将'includeSystemScope'设置为true.

you can set 'includeSystemScope' to true.

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <includeSystemScope>true</includeSystemScope>
  </configuration>
</plugin>

这篇关于将外部库.jar添加到Spring boot .jar内部/lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆