Java maven编译错误:文件名、目录名或卷标语法不正确

Java maven编译错误:文件名、目录名或卷标语法不正确,java,maven,compilation,Java,Maven,Compilation,我正在编译我的pom.xml文件,并得到以下编译错误 Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.5.1:copy-dependencies (copy-dependencies) on project ElasticSearchUtility: Error copying artifact from C:\Users\10641516\.m2\repository\org\apache\lu

我正在编译我的
pom.xml
文件,并得到以下编译错误

Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.5.1:copy-dependencies (copy-dependencies) on project ElasticSearchUtility: Error copying artifact from C:\Users\10641516\.m2\repository\org\apache\lucene\lucene-sandbox\7.1.0\lucene-sandbox-7.1.0.jar to D:\Karthikeyan\ElasticSearch\ElasticSearch_Tesing\target\dependency-
    [ERROR] jars\lucene-sandbox-7.1.0.jar: The filename, directory name, or volume label syntax is incorrect
但是所需的.jar文件在指定的路径中可用

我在maven项目中创建了两个java文件,一个是POJO类,另一个是java主类文件。我想让我的项目成为一个可执行的jar文件,我想使用
java-jar
命令在外部运行它

请找到我的pom.xml文件

<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>ElasticSearchUtility</groupId>
<artifactId>ElasticSearchUtility</artifactId>
<version>1.0.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>6.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>rest</artifactId>
        <version>5.1.2</version>
    </dependency>

</dependencies>

<build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>

            <!-- Set a compiler level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!-- Make this jar executable -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/log4j.properties</exclude>
                    </excludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>ProjectJar.project.App</mainClass>
                            <classpathPrefix>dependency-jars/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- Copy project dependency -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.5.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- exclude junit, we need runtime dependency only -->
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.build.directory}/dependency-
                                jars/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            </plugins>
    </build>
    </projects>

4.0.0
弹性搜索工具
弹性搜索工具
1.0.0-SNAPSHOT
org.elasticsearch
弹性搜索
6.1.2
org.elasticsearch.client
elasticsearch rest高级客户端
6.1.2
org.elasticsearch.client
休息
5.1.2
org.apache.maven.plugins
maven eclipse插件
2.9
真的
假的
org.apache.maven.plugins
maven编译器插件
2.3.2
1.8
1.8
org.apache.maven.plugins
maven jar插件
**/log4j.properties
真的
ProjectJar.project.App
依赖罐子/
org.apache.maven.plugins
maven依赖插件
2.5.1
复制依赖项
包裹
复制依赖项
运行时
${project.build.directory}/dependency-
罐子/

锯断错误消息:

  ... D:\Karthikeyan\ElasticSearch\ElasticSearch_Tesing\target\dependency- 
建议您需要将maven dependency插件的
outputDirectory
配置更改为:

                    <configuration>
                        <!-- exclude junit, we need runtime dependency only -->
                        <includeScope>runtime</includeScope>
                        <outputDirectory>
                            ${project.build.directory}/dependency-jars/
                        </outputDirectory>
                    </configuration>

运行时
${project.build.directory}/dependency jars/

为了消除中间的换行值。

谢谢。它修复了我的问题。现在,在执行JAR文件<代码>错误时,我会发现这个错误:找不到或加载主类ProjistJAR。Projtual.App。我的主要类包名是
com.es.utility.DocumentIndex
,所以我需要给出完整的包名而不是
ProjectJar.project.App
。。?(在我的pom.xml文件中)如果我添加
com.es.utility.DocumentIndex
am get
Error:找不到或加载主类com.es.utility.DocumentIndex
Error这听起来像是一个新问题。根据提供的信息,我们没有太多机会回答这个问题。我已经为这个错误创建了一个单独的问题-