其他分享
首页 > 其他分享> > Maven Scanning for projects... < org.example:MapReduceDemo > Building MapReduceDemo 1.0-SNAPSHOT BUI

Maven Scanning for projects... < org.example:MapReduceDemo > Building MapReduceDemo 1.0-SNAPSHOT BUI

作者:互联网

解决Maven打包时不报错,也不报异常,显示打包成功,但是没有打包出来的。包含build标签内容!异常信息如下:

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.example:MapReduceDemo >----------------------
[INFO] Building MapReduceDemo 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.113 s
[INFO] Finished at: 2021-12-14T18:29:09+08:00
[INFO] ------------------------------------------------------------------------

这个问题我在网上查询了很久也没有解决,问老师也没有解决,后来替换文件可以之后,去对比两个文件才发现问题


不能正确打包的配置文件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>org.example</groupId>
    <artifactId>MapReduceDemo</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>3.1.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.30</version>
        </dependency>
    </dependencies>
</project>

正确的配置文件如下:

<?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>org.example</groupId>
    <artifactId>MapReduceDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>3.1.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.30</version>
        </dependency>
    </dependencies>
</project>

加上build标签,上述两个文件都是能打包带依赖的jar包的,但是错误的一个只打包出了一个带依赖的jar包,而正确的个打包了两个jar包,一个带依赖,一个不带依赖。build标签内容如下:

<build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

找到问题在哪里没有?
问题如下照片:
在这里插入图片描述
在这里插入图片描述
到这里大家明白了吧,只需要把<packaging>pom</packaging>标签删掉即可!是不是很简单,是不是很意外!

标签:Building,Scanning,jar,MapReduceDemo,INFO,org,junit,打包
来源: https://blog.csdn.net/qq_43224174/article/details/121936126