Reputation: 110
I am trying to set up a Spring boot application with MongoDB connection to mLab. But when I try to run this test (or any other test)
@RunWith(SpringRunner.class)
@SpringBootTest
public class SyncrewApplicationTests {
@Test
public void contextLoads() {
}
}
I get this error:
Caused by: java.lang.ClassNotFoundException: org.springframework.data.rest.core.invoke.RepositoryInvokerFactory
My Spring boot application:
@SpringBootApplication
public class SyncrewApplication {
public static void main(String[] args) {
SpringApplication.run(SyncrewApplication.class, args);
}
}
The user MongoDB repository
@RepositoryRestResource(exported = false)
public interface UserRepository extends MongoRepository<User, Integer> {
User findUserByUsername(String username);
User findUserByEmail(String email);
}
User class
@Document(collection = "users")
public class User implements Serializable, UserDetails {
@Id
private String id;
private String username;
public User(){}
public User(String username){
this.username = username;
}
// getters and setters
I think my problem is in my pom.xml but I don't know where.. This are my dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Upvotes: 0
Views: 2338
Reputation: 2255
Your files seems perfect just add versions in the pom and It should work.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>RELEASE</version>
</dependency>
</dependencies>
RELEASE =1.5.1.RELEASE
Upvotes: 1