英文:
Spring Boot Jpastreamer - com.speedment.jpastreamer.application.JPAStreamer can not be found
问题
我在使用 Jpastreamer 运行我的 Spring Boot 应用时遇到了问题。
我无法解决与 Jpastreamer 相关的 bean 问题。
以下是下面显示的 PersonService:
@Service
@RequiredArgsConstructor
public class PersonService {
private final JPAStreamer jpaStreamer;
private final PersonRepository personRepository;
...
}
当我运行应用程序时,我收到了以下错误信息:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.springboot.jpastreamer.service.PersonService required a bean of type 'com.speedment.jpastreamer.application.JPAStreamer' that could not be found.
Action:
Consider defining a bean of type 'com.speedment.jpastreamer.application.JPAStreamer' in your configuration.
Process finished with exit code 0
这是仓库的链接:
英文:
I have a problem to run my Spring Boot with the usage of Jpastreamer.
I cannot solve the bean issue related with Jpastreamer.
Here is the PersonService shown below
@Service
@RequiredArgsConstructor
public class PersonService {
private final JPAStreamer jpaStreamer;
private final PersonRepository personRepository;
...
}
I got this issue shown below when I run the application.
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.springboot.jpastreamer.service.PersonService required a bean of type 'com.speedment.jpastreamer.application.JPAStreamer' that could not be found.
Action:
Consider defining a bean of type 'com.speedment.jpastreamer.application.JPAStreamer' in your configuration.
Process finished with exit code 0
Here is the repo shown below
答案1
得分: 0
在下面的JPAStreamerConfig
中将JPAStreamer
定义为一个bean
后,该问题消失了。
import com.speedment.jpastreamer.application.JPAStreamer;
import jakarta.persistence.EntityManagerFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@RequiredArgsConstructor
public class JPAStreamerConfig {
private final EntityManagerFactory entityManagerFactory;
@Bean
public JPAStreamer jpaStreamer() {
return JPAStreamer.of(entityManagerFactory);
}
}
英文:
After defining JPAStreamer
as a bean
in JPAStreamerConfig
shown below, the issue disappeared.
import com.speedment.jpastreamer.application.JPAStreamer;
import jakarta.persistence.EntityManagerFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@RequiredArgsConstructor
public class JPAStreamerConfig {
private final EntityManagerFactory entityManagerFactory;
@Bean
public JPAStreamer jpaStreamer() {
return JPAStreamer.of(entityManagerFactory);
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论