Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么maven不能将我的依赖项添加到jar?_Java_Maven_Dependency Management - Fatal编程技术网

Java 为什么maven不能将我的依赖项添加到jar?

Java 为什么maven不能将我的依赖项添加到jar?,java,maven,dependency-management,Java,Maven,Dependency Management,我是maven新手,我想做的一件简单的事情就是拉入maven存储库并在我的项目中使用它。 但这已经发生了 pom.xml 4.0.0 ToolsQA jutil_表 罐子 1.0-快照 jutil_表 http://maven.apache.org 朱尼特 朱尼特 3.8.1 测试 com.github.chrisgleissner 朱蒂尔普罗托布夫 1.1.11 org.apache.maven.plugins maven编译器插件 3.5.1 1.8 1.8 App.java packa

我是maven新手,我想做的一件简单的事情就是拉入maven存储库并在我的项目中使用它。 但这已经发生了

pom.xml


4.0.0
ToolsQA
jutil_表
罐子
1.0-快照
jutil_表
http://maven.apache.org
朱尼特
朱尼特
3.8.1
测试
com.github.chrisgleissner
朱蒂尔普罗托布夫
1.1.11
org.apache.maven.plugins
maven编译器插件
3.5.1
1.8
1.8
App.java

packagetoolsqa;
/**
*你好,世界!
*
*/
导入静态com.github.chrisgleissner.jutil.table.TablePrinter.DefaultTablePrinter;
导入静态java.util.Arrays.asList;
公共类应用程序
{
公共静态void main(字符串[]args)
{
System.out.println(“你好,世界!”);
Iterable HEADERS=asList(“id”、“name”、“age”);
DefaultTablePrinter.print(标题,空);
}
}
完整错误消息

[INFO]正在扫描项目。。。
[信息]
[信息]----------------------------------------------------
[信息]建筑jutil_表1.0-SNAPSHOT
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---maven clean插件:2.5:clean(默认清洁)@jutil_table---
[信息]删除C:\Users\Pawar\Desktop\mvn\U tutorial\jutil\u table\jutil\u table\target
[信息]
[信息]---maven资源插件:2.6:resources(默认资源)@jutil_table---
[警告]使用平台编码(实际上是Cp1252)复制过滤后的资源,即构建依赖于平台!
[信息]跳过不存在的资源目录C:\Users\Pawar\Desktop\mvn\u tutorial\jutil\u table\jutil\u table\src\main\resources
[信息]
[信息]---maven编译器插件:3.5.1:compile(默认编译)@jutil_table---
[信息]检测到更改-重新编译模块!
[警告]尚未使用平台编码Cp1252设置文件编码,即生成依赖于平台!
[信息]正在将1个源文件编译为C:\Users\Pawar\Desktop\mvn\U tutorial\jutil\U table\jutil\U table\target\classes
[信息]-------------------------------------------------------------
[错误]编译错误:
[信息]-------------------------------------------------------------
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,53]包com.github.chrisgleissner.jutil.table不存在
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,2]仅从类和接口静态导入
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[18,10]找不到符号
符号:可变默认表格打印机
位置:class ToolsQA.App
[信息]3个错误
[信息]-------------------------------------------------------------
[信息]------------------------------------------------------------------------
[信息]生成失败
[信息]------------------------------------------------------------------------
[信息]总时间:4.037秒
[信息]完成时间:2020-05-24T22:49:15+05:30
[信息]------------------------------------------------------------------------
[错误]无法在project jutil_上执行目标org.apache.maven.plugins:maven编译器插件:3.5.1:compile(默认编译):编译失败:编译失败:
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,53]包com.github.chrisgleissner.jutil.table不存在
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,2]仅从类和接口静态导入
[错误]/C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[18,10]找不到符号
[错误]符号:变量DefaultTablePrinter
[错误]位置:class ToolsQA.App
[错误]->[帮助1]
[错误]
[错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。
[错误]使用-X开关重新运行Maven以启用完整调试日志记录。
[错误]
[错误]有关错误和可能的解决方案的更多信息,请阅读以下文章:
[错误][帮助1]http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我读了很多关于stackoverflow的文章和相关问题。但maven仍然无法下载回购协议。而构建正在失败。 我用的是mvn编译,mvn包,mvn干净安装,对我来说什么都不管用。 请帮忙✌️

根据,您需要具有所有三个依赖项。您发布的问题与maven没有直接关系。也就是说编译器找不到符号,可能是因为类不在类路径中。尝试包含所有依赖项

或者在本例中,您真正需要的是
jutil表的依赖关系。你可以省略另外两个。但是您的maven pom包含
jutil protobuf
依赖项

<dependency>
    <groupId>com.github.chrisgleissner</groupId>
    <artifactId>jutil-protobuf</artifactId>
    <version>1.1.11</version>
</dependency>
<dependency>
    <groupId>com.github.chrisgleissner</groupId>
    <artifactId>jutil-sql-log</artifactId>
    <version>1.1.11</version>
</dependency>
<dependency>
    <groupId>com.github.chrisgleissner</groupId>
    <artifactId>jutil-table</artifactId>
    <version>1.1.11</version>
</dependency>

com.github.chrisgleissner
朱蒂尔普罗托布夫
1.1.11
com.github.chrisgleissner
jutil sql日志
1.1.11
com.github.chrisgleissner
朱蒂尔表
1.1.11
并使用maven assembly插件构建包含依赖项的jar

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass> // Main class Ex : com.Test </mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

maven汇编插件
包裹
单一的
//主类Ex:com.Test
带有依赖项的jar

您是否在本地回购协议中看到了jutil protobuf
jar?如果您打开它,是否会看到
DefaultTablePrinter
类文件?该版本是否在maven central中提供(如果您是我们的话)
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass> // Main class Ex : com.Test </mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>