當前我正在處理我公司的一個項目,該項目將XML數據導入到我們的數據庫。在這樣做的過程中,我依賴於已經創建並在其他項目中使用的一些基本配置項目,即EntityManagerBuilder
或其他用於創建與我們的oracle數據庫的連接的實用程序類。而在我看來,這些依賴關係正在給我造成一些問題。Maven安裝成功,但jar無法從bash(CLI)正常工作
如果我在eclipse中啓動它,我的項目運行得非常好。當我使用mvn clean install -DskipTests
創建該項目時,它的性能很好。 但是,當我想從命令行運行它時,應用程序會啓動並在幾行代碼停止後,不會拋出任何錯誤或異常。
我認爲它與某些依賴關係有關的原因是通過記錄我設法找到應用程序停止的位置。既然它停在了我可以調查的地方,我就是這麼做的。我下載了源代碼,只添加了一些日誌記錄,突然我的應用程序在該類中沒有任何問題,只是停止了對下一個類的下一個靜態調用。
我不知道在哪裏尋找錯誤。由於這是一個必須由它自己作爲月度任務運行的應用程序,因此不能從eclipse執行它。
希望有人能給我一個提示如何解決這個問題。
這裏是我的POM:
<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>
<parent>
<groupId>com.company.infrastructure.foo</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foo-import</artifactId>
<packaging>jar</packaging>
<name>FooImport</name>
<properties>
<company.consoleapp.main.class>com.company.infrastructure.foo.import.FooImporter</company.consoleapp.main.class>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.company.maven</groupId>
<artifactId>company-standalone-dm</artifactId>
<version>${company.parent.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<!-- Utilities -->
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<!-- Using foo-dataaccess -->
<dependency>
<groupId>com.company.infrastructure.marken</groupId>
<artifactId>foo-dataaccess</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>foo-import</finalName>
<plugins>
<!-- Consoleapp-Mixin -->
<plugin>
<groupId>com.github.odavid.maven.plugins</groupId>
<artifactId>mixin-maven-plugin</artifactId>
<configuration>
<mixins>
<mixin>
<groupId>com.company.maven</groupId>
<artifactId>company-consoleapp-mixin</artifactId>
<version>${company.parent.version}</version>
</mixin>
</mixins>
</configuration>
</plugin>
</plugins>
</build>
我認爲你對依賴管理是正確的。我現在正在研究它,看起來另一個jar在那裏,但它的一個SNAPSHOT版本,這不知怎的搞砸了。我正在用'java -jar foo-import.jar/data -o option'運行它。謝謝你指點我正確的方向。 – kaba713