我有一個項目,我想在當前項目的執行階段調用M2倉庫中的另一個Jar文件。我POM調用M2倉庫中的jar文件
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>exec-one</id> <phase>verify</phase> <configuration> executable>java</executable> <arguments> <argument>-jar</argument> <argument>JarToInvoke.jar</argument> </arguments> <**workingDirectory**>/C:/path to repo</workingDirectory> </configuration> <goals> <goal>exec</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>GroupId of JarToInvoke</groupId> <artifactId>JarToInvoke</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> </dependencies> </plugin> </plugins>
的
樣品骨架我試圖與Maven的EXEC-插件,但具有下列問題;
我在哪裏需要指定JarToInvoke依賴?作爲項目依賴項還是作爲exec-plugin依賴項?
通過硬編碼工作目錄(/ C:/ repo的路徑),我可以調用JarToInvoke工件。但這不是一個好的解決方案,因爲最後這個項目應該運行在任何具有不同操作系統的m/c上。那麼我怎樣才能讓exec-plugin在項目的M2倉庫(默認classpath)中搜索JarToInvoke工件呢?
3.在工作目錄中對M2 repo路徑進行硬編碼時,我能夠調用JarToInvoke工件。但是,在運行JarToInvoke工件時,會引發另一個依賴性問題,對JarToInvoke的某些log4j依賴關係找不到。我將JarToInvoke製作成陰影罐,並且按預期工作。但它不是一個永久的或很好的解決方案(因爲陰影的jar大小是35 MB)。我該如何指示exec-plugin在M2回購庫中尋找相關的Jars。
請分享您的建議。提前致謝。
感謝prunge的寶貴信息。但是,如上所述配置POM後,它會拋出以下異常; – appu 2012-03-23 10:51:05
'java.lang.reflect.InvocationTargetException \t at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) \t at sun.reflect.NativeMethodAccessorImpl。調用(NativeMethodAccessorImpl.java:39) \t在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) \t在java.lang.reflect.Method.invoke(Method.java:597) \t在org.codehaus .mojo.exec.ExecJavaMojo $ 1.run(ExecJavaMojo.java:297)\t在java.lang.Thread.run(Thread.java:662)' – appu 2012-03-23 11:04:01
@ RahulR.Prasad它看起來像一個不同版本的ASM庫的什麼JarToInvoke預期在執行JAR時被拉入。嘗試顯式地爲exec插件添加一個依賴項,以獲得您的'com.tvworks.testing.tools'類所需的asm版本。 – prunge 2012-03-23 16:59:10