使用Maven生成JAR

时间:2018-02-04 15:33:15

标签: java maven jar

在使用Maven生成JAR期间出现此错误:

  

Failed to execute goal on project TaskManagerTrue: Could not resolve dependencies for project groupId:TaskManagerTrue:jar:1.0: Could not find artifact groupId:TaskManagerTrue:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

我的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>groupId</groupId>
    <artifactId>TaskManagerTrue</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>groupId</groupId>
            <artifactId>TaskManagerTrue</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>test</finalName>
        <defaultGoal>package</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <goal>jar:inplace</goal>
                    <archive>
                        <manifestFile>META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <outputDirectory>artifacts</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

删除此声明解决了问题:

        <dependency>
            <groupId>groupId</groupId>
            <artifactId>TaskManagerTrue</artifactId>
            <version>1.0</version>
        </dependency>