相关疑难解决方法(0)

使用原型的新Maven项目:为什么要在POM中复制javaee-endorsed-api.jar?

我已经使用Maven archetype(webapp-javaee6)来创建一个新的Java EE 6项目,但是不明白为什么某些东西放在buildPOM 的元素中.具体来说,我不明白为什么将javaee-endorsed-api.jar其复制到背书目录.根据这个问题的答案,这是编译所需要的,但是当我删除相关plugin元素时,我的项目编译得很好build.

既然javax:javaee-web-api已经作为POM中的依赖项提供,那么这不能用于编译吗?

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

java maven

17
推荐指数
2
解决办法
6955
查看次数

标签 统计

java ×1

maven ×1