Java 在maven包期间添加执行main方法的依赖项

Java 在maven包期间添加执行main方法的依赖项,java,maven,Java,Maven,我将maven配置为在maven包期间调用main方法: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version>

我将maven配置为在maven包期间调用main方法:

           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.example.MyMainClass</mainClass>
                    <arguments>
                        <argument>arg1</argument>
                        <argument>arg2</argument>
                    </arguments>
                </configuration>
            </plugin>

为什么不想设置编译范围?那么在阅读编辑后,“必需”依赖项将位于何处?如果它是在环境类路径中提供的,那么作用域应该是“提供的”
provided
scope不起作用,我得到
java.lang.NoClassDefFoundError:org/jsoup/nodes/Node
。最后,我设置了
compile
范围。这仍然是一个悬而未决的问题,还是您的编辑显示您已经解决了原始问题?我通过将
excludegroupId
添加到
maven依赖插件
(正如我在编辑中所写)来解决我的问题但我仍然很好奇,是否可以只为
execmaven插件添加依赖项。我想为
org.jsoup
设置
提供的
范围,并将其添加到
类路径
中,仅用于执行
exec maven plugin
执行。为什么不想设置编译范围?那么在阅读编辑后,“必需”依赖项将位于何处?如果它是在环境类路径中提供的,那么作用域应该是“提供的”
provided
scope不起作用,我得到
java.lang.NoClassDefFoundError:org/jsoup/nodes/Node
。最后,我设置了
compile
范围。这仍然是一个悬而未决的问题,还是您的编辑显示您已经解决了原始问题?我通过将
excludegroupId
添加到
maven依赖插件
(正如我在编辑中所写)来解决我的问题但我仍然很好奇,是否可以只为
execmaven插件添加依赖项。我想为
org.jsoup
设置
提供的
范围,并将其添加到
classpath
中,仅用于
exec maven plugin
执行。
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <excludeGroupIds>org.jsoup</excludeGroupIds>
                </configuration>
            </plugin>