Maven 命令行mvn缺少依赖项
我有一个简单的程序。我从main调用一个URL,它就会打开。当我在intellij中运行它时,它工作正常,但命令行不工作。 另外,当我创建另一个java程序并导入这个jar时,我得到了相同的错误 这是我的POM.xml:Maven 命令行mvn缺少依赖项,maven,intellij-idea,Maven,Intellij Idea,我有一个简单的程序。我从main调用一个URL,它就会打开。当我在intellij中运行它时,它工作正常,但命令行不工作。 另外,当我创建另一个java程序并导入这个jar时,我得到了相同的错误 这是我的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/20
<?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>XMLConverter</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
</dependencies>
</project>
当我运行这个:mvn dependency:树时,我得到了正确的依赖关系
我的假设是因为我有两个.java文件。我有一个main,然后是代码。当它是一个文件XMLConverter时,它工作得很好。
在maven编译器插件中添加以下插件,要创建JAR,请在下面的mainclass标记下提及您的主类路径
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example. <Path to main class></mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins></build>
org.apache.maven.plugins
maven阴影插件
3.1.0
真的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
com.example。
在maven编译器插件中添加以下插件,要创建JAR,请在下面的mainclass标记下提及您的主类路径
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example. <Path to main class></mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins></build>
org.apache.maven.plugins
maven阴影插件
3.1.0
真的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
com.example。
这是否回答了您的问题?这回答了你的问题吗?