Tag: 弹簧引导

SpringBoot ArrayIndexOutOfBoundsException MethodParameter.getGenericParameterType

我正在使用spring引导,我试图建立一个测试场景,我调用一个bean,调用一个模拟JPARepository使用mockito。 这是相关的代码: 存储库 @Repository interface FooRepository : JpaRepository 服务 @Service class FooService( private val FooRepository: FooRepository ) { @Transactional fun call(input: String) = FooRepository.saveAndFlush( Foo(input) ) } 和测试 @SpringBootTest @RunWith(SpringRunner::class) @Import(FooServiceTest.MockFooRepositoryConfiguration::class) class FooServiceTest { @Autowired private lateinit var fooService: FooService @Autowired private lateinit var fooRepository: FooRepository @Test fun test1() { FooService.call(“xxx”) Mockito.verify(FooRepository, Mockito.times(1)).saveAndFlush(“xxx”) } @Configuration […]

StackOverflowError序列化递归JSON

我有一个基本的用户类,其中包括一个用户名和一个朋友variables: data class User ( val username: String, @ManyToMany(fetch = FetchType.EAGER) @JoinTable( name = “users_friends”, joinColumns = arrayOf(JoinColumn(name = “user_id”, referencedColumnName = “id”)), inverseJoinColumns = arrayOf(JoinColumn(name = “friends_id”, referencedColumnName = “id”))) val friends: Collection?) 我从一个springboot控制器调用内置的kotlin函数getFriends(): @ApiOperation(“Get Friends”) @RequestMapping(value = “/friends”, method = RequestMethod.GET) public Collection getFriends(@RequestParam final String username) { return userService.getFriends(userService.findByUsername(username).get()); } 其中调用该服务: @Override […]

在Spring Boot M7和MongoDB中找不到ReflectKotlinClass

如果使用Web和MongoDB模块在start.spring.io上创建一个新的Spring Boot项目,请添加任何@Document注释类,并且将kotlin.version从1.2.10升级到1.2.21,您将得到一个NoClassDefFoundError: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M7:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name ‘mongoTemplate’ defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘mongoTemplate’ parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘mappingMongoConverter’ defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied […]