0

Maven と、コマンド ラインからの Java クラス呼び出しの実行に問題があります。

私のアプリケーションは、春、休止状態、および Maven を使用しています。

私の小さなpom.xmlはこれです:

<profile>
<id>import</id>
<build>
 <plugins>
  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <executions>
    <execution>
     <goals>
      <goal>java</goal>
     </goals>
     <phase>test</phase>
      <configuration>
        <mainClass>com.mycompany.App</mainClass>
      </configuration>
     </execution>
    </executions>
  </plugin>
 </plugins>
</build>
</profile>

私はEclipseから実行しようとしましたが、私のアプリケーションは動作しますが、コマンドラインでは次のようになります: mvn test -Pimport 次のようなエラーがいくつかあります:

"nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory"

例:依存関係は次のように定義されています:

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>

助言がありますか?

ありがとう

4

1 に答える 1

2

これと同じ問題があると思います。クラスパスにも実装 jar が必要です。例えば

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.5.8</version>
        </dependency>

pom.xml で slf4j について言及しているものは他にありますか?

于 2013-05-23T17:00:53.647 に答える