Spring Boot Jpastreamer – com.speedment.jpastreamer.application.JPAStreamer 无法找到

huangapple go评论103阅读模式
英文:

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

Link

答案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);
    }

}

huangapple
  • 本文由 发表于 2023年7月14日 04:26:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定