mojo exec的maven依赖范围:java

时间:2014-01-31 19:24:15

标签: maven

我想用jmeter测试运行本地activemq代理:

mvn exec:java -PJMeterProfile

我在提供的范围内有一些deps,导致java.lang.NoClassDefFoundError,如

            <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                    <version>1.6.4</version>
                    <scope>provided</scope>
            </dependency>
            <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                    <version>1.6.4</version>
                    <scope>provided</scope>
            </dependency>
            <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.17</version>
                    <scope>provided</scope>
            </dependency>

是否有一些适用于maven的范围仅为exec:java提供此类? 或者仅在exec:java?

中提供此依赖关系的其他方式

已解决将添加依赖项添加到mojo插件中,例如tom(并添加includePluginDependencies为true):

                    <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>exec-maven-plugin</artifactId>
                            <configuration>
                                    <mainClass>${target.main.class}</mainClass>
                                    <commandlineArgs>${target.cmd.args}</commandlineArgs>
                                    <includePluginDependencies>true</includePluginDependencies>
                            </configuration>
                            <dependencies>
                                    <dependency>
                                            <groupId>org.slf4j</groupId>
                                            <artifactId>slf4j-api</artifactId>
                                            <version>1.6.4</version>
                                            <scope>compile</scope>
                                    </dependency>
                                    <dependency>
                                            <groupId>org.slf4j</groupId>
                                            <artifactId>slf4j-log4j12</artifactId>
                                            <version>1.6.4</version>
                                            <scope>compile</scope>
                                    </dependency>
                                    <dependency>
                                            <groupId>log4j</groupId>
                                            <artifactId>log4j</artifactId>
                                            <version>1.2.17</version>
                                            <scope>compile</scope>
                                    </dependency>
                            </dependencies>
                    </plugin>

1 个答案:

答案 0 :(得分:1)

我相信你可以将依赖项添加到插件本身。这样,它们就会在插件执行时添加。

查看this网址。