java - POM打包option jar to war改错

标签 java spring eclipse maven spring-boot

您好,我正在尝试将我的 pom.xml 中的打包选项从 jar 更改为 war。但是当每次更改时,这都会导致错误。这样我就无法为我的 spring boot 应用程序创建 war 文件。

我的 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.domain</groupId>
    <artifactId>AsBuilt-MS</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>AsBuilt-MS</name>
    <description>Demo project for AsBuilt-MS Application</description>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <start-class>com.domain.AsBuiltMS.AsBuiltMsApplication</start-class>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-binding -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-binding</artifactId>
            <version>1.0.6</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <addResources>true</addResources>
                </configuration>
            </plugin>
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>
</project>

错误信息

Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'AsBuilt-MS'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:3.2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:3.2.2
Plugin org.apache.maven.plugins:maven-war-plugin:3.2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:3.2.2
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:3.2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:3.2.2
Plugin org.apache.maven.plugins:maven-war-plugin:3.2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:3.2.2

所以谁能知道如何解决这个问题。

最佳答案

由于您使用公司代理,因此需要在 settings.xml 中配置两个代理条目:一个用于 http,另一个用于 https 协议(protocol)。

<proxy> 
<id>http-proxy</id> 
<active>true</active> 
<protocol>http</protocol> 
<username>proxyuser</username> 
<password>proxypass</password> 
<host>proxy.host.net</host> 
<port>80</port> 
<nonProxyHosts>local.net|some.host.com</nonProxyHosts> 
</proxy> 

<proxy> 
<id>https-proxy</id> 
<active>true</active> 
<protocol>https</protocol> 
<username>proxyuser</username> 
<password>proxypass</password> 
<host>proxy.host.net</host> 
<port>80</port> 
<nonProxyHosts>local.net|some.host.com</nonProxyHosts> 
</proxy> 

关于java - POM打包option jar to war改错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55489659/

相关文章:

java - 在 Spring-MVC 中,如何动态设置 session 属性的构造函数参数?

java - 部署 war : No Spring WebApplicationInitializer types detected on classpath

java - 安卓java.lang.RuntimeException : Unable to resume activity

java - Eclipse 插件激活器类

java - 如何从我的 Opendaylight 项目中查看调试日志

java - 从类中调用已实现的接口(interface)重写方法

java - 如何使用 JSP 更新 XML 文件

java - 使用 application.properties 注入(inject)同一类的多个 Spring Bean

java - 严重 : Error configuring application listener of class org. apache.catalina.deploy.ApplicationListener

java - Hadoop MapReduce 中的 Reducer 类未按预期工作