当与mvn clean程序包一起打包时,正在运行的Jar不使用lib/*中的jars [英] Running Jar does not use jars from lib/* when packaged with mvn clean package

查看:207
本文介绍了当与mvn clean程序包一起打包时,正在运行的Jar不使用lib/*中的jars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个spring-boot应用程序,它首先打包到jar中 使用

I have spring-boot application, which is first packaged to jar using

mvn clean package

我试图以

java -jar target/bootstep-0.0.1-SNAPSHOT.jar

但是由于以下错误而失败.

But it fails due to following error.

2015-04-24 16:06:45.425  INFO 27324 --- [ost-startStop-1] c.s.j.api.core.PackagesResourceConfig    : Scanning for root resource and provider classes in the packages:
  com.netflix.discovery
  com.netflix.eureka
2015-04-24 16:06:45.470 ERROR 27324 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Exception starting filter servletContainer

com.sun.jersey.core.spi.scanning.ScannerException: IO error when scanning jar 
..
..
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\springbootproject\target\bootstep-0.0.1-SNAPSHOT.jar!\lib\eureka-client-1.1.147.jar (The system cannot find the path specified)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at com.sun.jersey.core.spi.scanning.uri.JarZipSchemeScanner.closing(JarZipSchemeScanner.java:123)
    at com.sun.jersey.core.spi.scanning.uri.JarZipSchemeScanner.scan(JarZipSchemeScanner.java:75)

Jar文件eureka-client-1.1.147.jar存在于jar的lib文件夹中,MANIFEST.MF也包含该文件.

Jar file eureka-client-1.1.147.jar is present in lib folder inside jar and MANIFEST.MF also has entry of it.

请提出建议.

推荐答案

该问题是由于Jersey的限制所致-它无法处理嵌套的JAR文件.您需要将Boot配置为在应用启动时自动解压缩任何包含JAX-RS资源的JAR,例如:

The problem's due to a limitation in Jersey – it can't cope with nested JAR files. You need to configure Boot to automatically unpack any JARs containing JAX-RS resources when your app launches, for example:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <requiresUnpack>
            <dependency>
                <groupId>com.netflix.eureka</groupId>
                <artifactId>eureka-core</artifactId>
            </dependency>
            <dependency>
                <groupId>com.netflix.eureka</groupId>
                <artifactId>eureka-client</artifactId>
            </dependency>
        </requiresUnpack>
    </configuration>
</plugin>

这篇关于当与mvn clean程序包一起打包时,正在运行的Jar不使用lib/*中的jars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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