spring-data

Spring Data - MongoDB - JUnit test

点点圈 提交于 2021-02-10 09:33:06
问题 I would have a question concerning Spring Data - MongoDB and JUnit test. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = { UserRepository.class, User.class }) public class MyJUnitTest { The UserRepository looks like this: @Repository public interface UserRepository extends MongoRepository<User, String> { User findByUsername(final String username); } I get the following Exception: Failed to instantiate [... .repository.UserRepository]: Specified class is an

Couldn't find type java.sql.Date. Are you missing a dependency on your classpath?

主宰稳场 提交于 2021-02-10 07:34:23
问题 I'm trying to run my application in Spring Boot using MongoDB with spring-data but I can't because IntelliJ shows me this error during build: Error:java: Couldn't find type java.sql.Date. Are you missing a dependency on your classpath? I'm using mongo java driver version 3.8.2, spring boot 2.1 and project is in Java 11. I have no idea what is wrong here could someone help me please? 回答1: Settings -> Build, Execution, Deployment -> Build Tools -> Maven/Gradle -> Runner -> tic on "Delegate IDE

Couldn't find type java.sql.Date. Are you missing a dependency on your classpath?

只愿长相守 提交于 2021-02-10 07:33:57
问题 I'm trying to run my application in Spring Boot using MongoDB with spring-data but I can't because IntelliJ shows me this error during build: Error:java: Couldn't find type java.sql.Date. Are you missing a dependency on your classpath? I'm using mongo java driver version 3.8.2, spring boot 2.1 and project is in Java 11. I have no idea what is wrong here could someone help me please? 回答1: Settings -> Build, Execution, Deployment -> Build Tools -> Maven/Gradle -> Runner -> tic on "Delegate IDE

Couldn't find type java.sql.Date. Are you missing a dependency on your classpath?

送分小仙女□ 提交于 2021-02-10 07:33:48
问题 I'm trying to run my application in Spring Boot using MongoDB with spring-data but I can't because IntelliJ shows me this error during build: Error:java: Couldn't find type java.sql.Date. Are you missing a dependency on your classpath? I'm using mongo java driver version 3.8.2, spring boot 2.1 and project is in Java 11. I have no idea what is wrong here could someone help me please? 回答1: Settings -> Build, Execution, Deployment -> Build Tools -> Maven/Gradle -> Runner -> tic on "Delegate IDE

Spring first request very slow

孤街浪徒 提交于 2021-02-09 11:48:36
问题 I have application in Spring Boot. After initialization of Spring Boot with embeded tomcat, the first response is very slow. How can I fix it? Has spring boot any warmup command/mode? I am thinking too about connection with database and I am wondering about connection database, probably spring connects with Postgres during first request. 回答1: You could either use ApplicationRunner or CommandlineRunner to run something on startup: https://docs.spring.io/spring-boot/docs/current/reference

Spring Data MongoDB Slow MongoTemplate.find() Performance

青春壹個敷衍的年華 提交于 2021-02-09 09:57:38
问题 I'm having performance issues when querying ~12,000 user documents, indexed by 1 column, (companyId), no other filter. The whole collection only has ~27000. It took me about 12 seconds to get the ~12000 rows of data... I tried running explain for this query: db.instoreMember.find({companyId:"5b6be3e2096abd567974f924"}).explain(); result follows: { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "production.instoreMember", "indexFilterSet" : false, "parsedQuery" : { "companyId" : { "$eq

Spring Data MongoDB Slow MongoTemplate.find() Performance

China☆狼群 提交于 2021-02-09 09:57:12
问题 I'm having performance issues when querying ~12,000 user documents, indexed by 1 column, (companyId), no other filter. The whole collection only has ~27000. It took me about 12 seconds to get the ~12000 rows of data... I tried running explain for this query: db.instoreMember.find({companyId:"5b6be3e2096abd567974f924"}).explain(); result follows: { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "production.instoreMember", "indexFilterSet" : false, "parsedQuery" : { "companyId" : { "$eq

Configuring base package for component scan in Spring boot test

人盡茶涼 提交于 2021-02-08 12:20:01
问题 When I launch my test with the following annotations: package com.hello.package.p1; @RunWith(SpringRunner.class) @DataMongoTest @SpringBootTest public class ClassATest { @Autowired Service1 serivce1; //fqn = com.hello.package.p1.Service1 @Autowired Service2 serivce2; //fqn = com.hello.package.p2.Service2 ...} package com.hello.package.p1; @ActiveProfiles("test") @SpringBootConfiguration public class MongoTestConfig { ... } service1 will be injected. But service2 will not, since it is not in

Configuring base package for component scan in Spring boot test

不打扰是莪最后的温柔 提交于 2021-02-08 12:17:58
问题 When I launch my test with the following annotations: package com.hello.package.p1; @RunWith(SpringRunner.class) @DataMongoTest @SpringBootTest public class ClassATest { @Autowired Service1 serivce1; //fqn = com.hello.package.p1.Service1 @Autowired Service2 serivce2; //fqn = com.hello.package.p2.Service2 ...} package com.hello.package.p1; @ActiveProfiles("test") @SpringBootConfiguration public class MongoTestConfig { ... } service1 will be injected. But service2 will not, since it is not in

How to configure multiple datasources in Spring Data JDBC?

为君一笑 提交于 2021-02-08 09:36:06
问题 I'm trying to replace some projects to use Spring Data JDBC instead of using JdbcTemplate . Now, I'd like to use it for multiple DataSource s, how can I configure it in Spring Data JDBC? 回答1: There is currently no support for working with two or more DataSource s. You'd have to manually redo what the JdbcRepositoryFactoryBean does. 来源: https://stackoverflow.com/questions/49914310/how-to-configure-multiple-datasources-in-spring-data-jdbc