首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Maven - WEB-INF/lib中不包含的可选依赖项

Maven - WEB-INF/lib中不包含的可选依赖项
EN

Stack Overflow用户
提问于 2015-07-16 03:33:46
回答 2查看 1.4K关注 0票数 2

我有一个maven war模块,它在pom.xml中声明了几个可选的依赖项。在eclipse中,这些选项依赖项显示为构建路径的一部分,这是我所期望的。但是在打包war文件时,maven没有在WEB-INF/lib文件夹中包含这些依赖项,根据maven doc:https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html,这是不正确的。你知道为什么会这样吗?

下面是完整的pom.xml

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <artifactId>dhive</artifactId>
    <groupId>com.boss</groupId>
    <version>1.0</version>
</parent>

<artifactId>Boss</artifactId>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>uk.com.robust-it</groupId>
        <artifactId>cloning</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>net.sf.jt400</groupId>
        <artifactId>jt400</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc14</artifactId>
        <optional>true</optional>
    </dependency>       
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.qoppa</groupId>
      <artifactId>jPDFProcess</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.arch</groupId>
      <artifactId>multivalent</artifactId>
        <optional>true</optional>
    </dependency>       
    <dependency>
      <groupId>com.arch</groupId>
      <artifactId>multivalentArch</artifactId>
        <optional>true</optional>
    </dependency>   
    <dependency>
      <groupId>org.jpedal</groupId>
      <artifactId>jpedal</artifactId>
        <optional>true</optional>
    </dependency>   
    <dependency>
      <groupId>com.arch</groupId>
      <artifactId>invoiceTool</artifactId>
        <optional>true</optional>
    </dependency>   
    <dependency>
       <groupId>com.sun</groupId>
       <artifactId>tools</artifactId>
       <version>1.6.0</version>
       <scope>system</scope>
       <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
     </dependency>                  
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>BossClient</id>
                    <configuration>
                        <ejbVersion>3.1</ejbVersion>
                        <generateClient>true</generateClient>
                        <clientIncludes>
                            <clientInclude>/com/**</clientInclude>
                        </clientIncludes>
                    </configuration>
                    <goals>
                        <goal>ejb</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

EN

回答 2

Stack Overflow用户

发布于 2015-07-16 23:14:10

在Maven WAR插件中创建了一个问题,https://issues.apache.org/jira/browse/MWAR-351

为了解决这个问题,我最终不得不删除

代码语言:javascript
运行
复制
<optional>true</optional> 

从ejb war模块中获取,以使其正常工作。对于需要此war模块中的ejb-client的所有其他项目/模块,我最终不得不进行排除,以避免将其依赖项添加到这些项目/模块中(见下文)。

代码语言:javascript
运行
复制
  <dependency>
    <groupId>com.boss</groupId>
    <artifactId>Boss</artifactId>
    <version>1.0</version>
    <type>ejb-client</type>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>       
</dependency>
票数 1
EN

Stack Overflow用户

发布于 2015-07-16 04:43:38

我猜您需要在pom.xml中更改您的plugin尝试添加以下插件

代码语言:javascript
运行
复制
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31439479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档