简体   繁体   中英

Why aren't test dependencies compiledin Maven?

I'm trying to use Morphia (MongoDB) in a Tomcat application. But I'm getting this Error:

错误消息:SLF4J:未找到 SLF4J 提供程序。 SLF4J:默认为无操作 (NOP) 记录器实现 SLF4J:有关详细信息,请参阅 http://www.slf4j.org/codes.html#noProviders。线程“pool-1-thread-1”中的异常 java.lang.NoClassDefFoundError: org/bson/conversions/Bson at dev.morphia.Morphia.createDatastore(Morphia.java:90)

The given link confirms that the JAR files are missing.

In the pom.xml file Morphia is added with compile as scope.

<dependency>
    <groupId>dev.morphia.morphia</groupId>
    <artifactId>core</artifactId>
    <version>1.5.3</version>
    <scope>compile</scope>
</dependency>

All dependencies are added as library and are useable inside Eclipse.

Maven 库

But only Morphia itself is being compiled.

With a look at MVNrepository I suspected that only "Compile Dependencies" and not "Test Dependencies" are being compiled.

But adding SLF4J API additionally to pom.xml didn't change anything.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.8.0-beta2</version>
    <scope>compile</scope>
</dependency>

Like @eis and the given link said I had to add a provider, not only the API.

But also the Versions were incompatible. If anyone else has this problem use this versions:

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.2.3</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>dev.morphia.morphia</groupId>
    <artifactId>morphia-core</artifactId>
    <version>2.1.5</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.8.0-beta2</version>
    <scope>compile</scope>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM