1

这是我的 pom.xml:

    <groupId>com.securebort.services</groupId>
    <artifactId>services</artifactId>
    <version>0.0.2</version>
    <packaging>jar</packaging> 

    <name>services</name>
    <description>Cipherworks services exposed to the client applications</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version> 
        <relativePath/> 
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
        <beanstalk.versionLabel>${maven.build.timestamp}</beanstalk.versionLabel>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
                        <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
                        <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>

        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
                        <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
           <groupId>org.apache.tomcat</groupId>
           <artifactId>tomcat-jdbc</artifactId>
           <version>9.0.1</version>
        </dependency>

        <dependency>
           <groupId>com.cipherworks</groupId>
           <artifactId>cwcommon</artifactId>
           <version>0.0.1</version>
        </dependency>       
        <dependency>
           <groupId>securebort</groupId>
           <artifactId>datacrypt</artifactId>
           <version>0.0.1</version>
        </dependency>
        <dependency>
           <groupId>com.cwkit</groupId>
           <artifactId>cwkit</artifactId>
         <version>0.0.1</version>
        </dependency>
        <dependency>
           <groupId>com.cipherworks</groupId>
           <artifactId>iam</artifactId>
           <version>0.0.1</version>
        </dependency>                 

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>                         
    </dependencies>
    <build>
        <plugins>       
              <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.0.4.RELEASE</version> 
              <configuration>
                 <layout>JAR</layout>
                 <mainClass>com.cipherworks.services.ServicesApplication</mainClass>
                </configuration> 
              <executions>
                  <execution>
                      <goals>
                         <goal>repackage</goal>
                      </goals>
                   </execution>
               </executions>
          </plugin>  
        </plugins>
    </build>

当我做 mvn package 时,它​​会创建一个重新打包的 jar 文件。但是重新打包的 jar 不包含我的依赖项 cwcommon、datacrypt 和 cwkit jar。我检查了我的本地存储库,它有我所有的依赖 jar 文件。出于某种原因,它们没有被重新包装到胖罐中。

目标依赖项的输出:树:由于堆栈溢出的大小限制,我无法复制和粘贴所有输出。我只复制了具有我的依赖项的部分。

....
....
....
[DEBUG] Using local repository at C:\Users\CipherWorks\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\CipherWorks\.m2\repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project com.securebort.services:services:jar:0.0.2: (none)
[DEBUG] Looking up lifecyle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.springframework.boot:spring-boot-dependencies:pom:2.0.4.RELEASE: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Resolving plugin prefix dependency from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix dependency to org.apache.maven.plugins:maven-dependency-plugin from POM com.securebort.services:services:jar:0.0.2
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: com.securebort.services:services:jar:0.0.2
[DEBUG] Tasks:   [dependency:tree]
[DEBUG] Style:   Regular
[DEBUG] =======================================================================
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building services 0.0.2
....
....
....
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project:       com.securebort.services:services:0.0.2
....
....
[DEBUG]       org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.32:provided
[DEBUG]       org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.32:provided
[DEBUG]       org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.32:provided
[DEBUG]    org.apache.tomcat:tomcat-jdbc:jar:9.0.1:compile
[DEBUG]       org.apache.tomcat:tomcat-juli:jar:9.0.1:compile
[DEBUG]    com.cipherworks:cwcommon:jar:0.0.1:compile
[DEBUG]    securebort:datacrypt:jar:0.0.1:compile
[DEBUG]    com.cwkit:cwkit:jar:0.0.1:compile
[DEBUG]       com.google.code.gson:gson:jar:2.8.5:compile (version managed from 2.6.2 by org.springframework.boot:spring-boot-dependencies:2.0.4.RELEASE)
[DEBUG]       org.slf4j:slf4j-api:jar:1.7.25:compile (version managed from 1.7.24 by org.springframework.boot:spring-boot-dependencies:2.0.4.RELEASE)
[DEBUG]       com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.9.6:compile (version managed from 2.9.5 by com.fasterxml.jackson:jackson-bom:2.9.6)
[DEBUG]          com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
....
....
[DEBUG]          org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[DEBUG]          com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[DEBUG]    com.cipherworks:iam:jar:0.0.1:compile
[DEBUG]       com.amazonaws:aws-java-sdk:jar:1.11.396:compile
[DEBUG]          com.amazonaws:aws-java-sdk-dlm:jar:1.11.396:compile
.....
.....
[DEBUG]   (f) outputType = text
[DEBUG]   (f) project = MavenProject: com.securebort.services:services:0.0.2 @ C:\git\services\pom.xml
[DEBUG]   (f) reactorProjects = [MavenProject: com.securebort.services:services:0.0.2 @ C:\git\services\pom.xml]
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@3872bc37
...
...
[DEBUG]       org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.32:provided
[DEBUG]       org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.32:provided
[DEBUG]    org.apache.tomcat:tomcat-jdbc:jar:9.0.1:compile
[DEBUG]       org.apache.tomcat:tomcat-juli:jar:9.0.1:compile
[DEBUG]    com.cipherworks:cwcommon:jar:0.0.1:compile
[DEBUG]    securebort:datacrypt:jar:0.0.1:compile
[DEBUG]    com.cwkit:cwkit:jar:0.0.1:compile
[DEBUG]       com.google.code.gson:gson:jar:2.8.5:compile (version managed from 2.6.2 by org.springframework.boot:spring-boot-dependencies:2.0.4.RELEASE)
...
...
[DEBUG]          com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.6:compile
[DEBUG]          org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[DEBUG]          com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[DEBUG]    com.cipherworks:iam:jar:0.0.1:compile
[DEBUG]       com.amazonaws:aws-java-sdk:jar:1.11.396:compile
[DEBUG]          com.amazonaws:aws-java-sdk-dlm:jar:1.11.396:compile
...
...
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.32:provided
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.32:provided
[INFO] +- org.apache.tomcat:tomcat-jdbc:jar:9.0.1:compile
[INFO] |  \- org.apache.tomcat:tomcat-juli:jar:9.0.1:compile
[INFO] +- com.cipherworks:cwcommon:jar:0.0.1:compile
[INFO] +- securebort:datacrypt:jar:0.0.1:compile
[INFO] +- com.cwkit:cwkit:jar:0.0.1:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
...
...

我的依赖项(cwkit、cwcommon、datacrypt、iam)显示在 INFO 输出中。但它们并没有被包含在脂肪罐中。

4

2 回答 2

1

不幸的是,没有足够的信息来说明为什么不包括罐子。唯一可能影响事物的属性是excludes,看起来你的 POM 中没有设置。

我猜您无法共享整个项目,并且您无法在较小的样本中复制该问题。真正剩下的唯一选择是自己调试插件。以下是您可以这样做的方法。

1) 在 POM 文件中使用的标记版本签出 Spring Boot 代码库:

$ git clone https://github.com/spring-projects/spring-boot.git
$ cd spring-boot
$ git fetch --tags
$ git checkout v2.0.4.RELEASE

2) 将spring-boot-maven-pluginandspring-boot-loader-tools导入您最喜欢的 IDE。

您应该能够只导入该项目。它是否不编译并不重要,因为我们只需要启动远程调试器并设置到代码中。

3)使用运行你的Maven构建mvnDebug

您需要安装完整版本的 Maven 才能执行此操作。

$ cd ~/myproject
$ mvnDebug package

4)附加远程调试器

Maven 应该输出如下内容:

Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000

返回您的 IDE 并在此处添加断点,然后在端口 8000 上启动远程调试会话。

5) 调试

您现在可以进入代码并查看发生了什么。您将特别希望查看Repackager以查看是否正在编写库。您的问题的一个可能原因是该isZip方法返回false. 检查该方法的结果并查看您的库是否确实有效的 zip 文件?

于 2018-09-13T05:33:46.947 回答
0

当我在 pom.xml 的属性下添加 maven.test.skip = true 时,问题就消失了。感谢您提供有用的提示。

于 2018-09-16T15:24:35.117 回答