maven - 如何使用 NetBeans 将对 Maven Web 应用程序资源 (WAR) 项目的额外依赖项添加到 Maven 存储库?

标签 maven tomcat netbeans jar maven-dependency

我在将“catalina-6.0.26.jar”依赖项(.jar 文件)添加到我的 Maven 存储库时遇到问题,以便它显示在查询文本框的“添加依赖项”窗口中NetBeans 集成开发环境。 出于某种原因,maven 存储库似乎不允许我在 .m2/repository 目录中已有的内容之外添加任何额外的依赖项。 下面的链接显示的是我在文本框中使用查询时可以访问的有限依赖项的屏幕截图: enter image description here

pom.xml 在这里:

<?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>

<groupId>com.proxysecure</groupId>
<artifactId>proxy-web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>proxy-web</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

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

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</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>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

最佳答案

将此添加到 <dependencies> pom.xml 中的部分并保存。

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>catalina</artifactId>
    <version>6.0.26</version>
    <scope>provided</scope>
</dependency>

运行 mvn clean install

关于maven - 如何使用 NetBeans 将对 Maven Web 应用程序资源 (WAR) 项目的额外依赖项添加到 Maven 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54918375/

相关文章:

java - 线程 "main"java.net.BindException : Address already in use - Error in Netbeans only 中的异常

java - Lombok 没有在 Maven 中编译

java - 如何正确构建java maven项目的jar文件?

tomcat - 热代码用Maven部署tomcat

Maven - 从外部属性文件中读取属性

java - iis 8 java 和 .net 网络服务

java - 如何在运行时从连接池声明中获取用户名

java - NetBeans 在非公共(public)类中运行带有 main 的 Java 程序

http - 使用 AJP/Tomcat 6.0 设置最大 HTTP header 大小

c++ - 使用 Netbeans 在 C++ 中包含 <string>