728x90
spring boot with mongodb error
//error
at com.aks.springStorage.SpringStorageApplication.main(SpringStorageApplication.java:22) [classes/:na]
Caused by: org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "testDB" }' on server localhost:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "testDB" }' on server localhost:27017
public interface CompanyRepository extends MongoRepository<Company, String> {
List<Company> findByName(String name);
@Query("{'id': ?0}")
List<TestDB> findById(String id);
}
@Data
@Document(collation = "testDB") // 바로 이 부분이 이번 오류의 원인
public class TestDB {
private int id;
private String name;
private String contact;
}
@Data
@Document(collection = "testDB") // collation이 아닌 collection으로 적어야한다.
public class TestDB {
private int id;
private String name;
private String contact;
}
728x90
'Spring > Spring Boot' 카테고리의 다른 글
[Spring Boot] Spring Boot 3.x 실행 안될 경우 (0) | 2023.04.24 |
---|---|
DB 연동 에러 HikariPool-1 - Exception during pool initialization (0) | 2022.11.30 |
spring-boot, react, axios 사용시 Cors, session, cookie 문제 (0) | 2022.03.04 |
Spring boot Rebuild없이 정적소스(HTML,CSS,js) 적용방법 (0) | 2022.02.25 |
JPA & PostgreSQL 연동 (0) | 2021.09.03 |
댓글