【问题标题】:jar-with-dependencies not include external repositoriesjar-with-dependencies 不包括外部存储库
【发布时间】:2013-06-22 03:22:21
【问题描述】:

我正在尝试用我的pom.xml 做一个可执行的 jar,但不包括 couchbase 外部存储库。

在 Eclipse 中一切正常。我通过以下方式在 pom 中有 couchbase 客户端:

<repositories>
    <repository>
        <id>couchbase</id>
        <name>Couchbase Maven Repository</name>
        <layout>default</layout>
        <url>http://files.couchbase.com/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

...

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.1.3</version>
</dependency>
<dependency>
    <groupId>couchbase</groupId>
    <artifactId>couchbase-client</artifactId>
    <version>1.1.7</version>
    <scope>provided</scope>
</dependency>

还有插件:

   <plugin>
     <artifactId>maven-assembly-plugin</artifactId>
     <configuration>
       <archive>
         <manifest>
           <mainClass>fully.qualified.MainClass</mainClass>
         </manifest>
       </archive>
       <descriptorRefs>
         <descriptorRef>jar-with-dependencies</descriptorRef>
       </descriptorRefs>
     </configuration>
     <executions>
       <execution>
         <id>make-assembly</id> <!-- this is used for inheritance merges -->
         <phase>package</phase> <!-- bind to the packaging phase -->
         <goals>
           <goal>single</goal>
         </goals>
       </execution>
     </executions>
   </plugin>

但是com.fasterxml.jackson.core包含在jar中,但是com.couchbase.client...没有

提前致谢。

【问题讨论】:

    标签: java maven-2 maven-plugin executable-jar maven-assembly-plugin


    【解决方案1】:

    您将 couchbase-client 的范围定义为“已提供”,这意味着:您在编译时需要它,但不需要部署它,因为无论代码在哪里运行,必要的类都已经存在(例如 Java EE在 Java EE 应用程序服务器中运行 Java EE 应用程序时的 API 类)。

    所以问题是:“提供”的范围是否正确?

    【讨论】:

      【解决方案2】:

      尝试从 couchbase-client 依赖项中删除“提供”范围。这表明程序集插件不包含此依赖项,因为无论如何它都会在运行时提供

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-07-31
        • 2012-01-31
        • 2020-08-02
        • 1970-01-01
        • 1970-01-01
        • 2011-07-13
        • 1970-01-01
        相关资源
        最近更新 更多