我花了一天的时间试图理解,但我无法理解我的问题。
我有 1 个弹簧模块(https://spring.io/guides/gs/multi-module/)[我在子模块中也有 JPA] 和 2 个微服务(A 和 B)。
在微服务 A 中,我到达 @Autowired CountryRepository(从 JpaRepository 扩展而来),它运行良好,SpringBootApplication (scanBasePackages = "**") 使用,我访问我的数据并且我可以编译。
在微服务 B 上,我做了同样的事情,我设法访问了我的数据,但无法编译:
****************************
FAILED TO START APPLICATION
****************************
Description:
Field countryRepository in * required a bean named 'entityManagerFactory' that could not be found.
The injection point has the following annotations:
- @ org.springframework.beans.factory.annotation.Autowired (required = true)
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
我无法理解或寻找错误,如何解锁自己,我一次又一次地搜索,但我无法理解为什么微服务 B 不想编译。
我使用 POM 父级,并且小心地按以下顺序排列:
<modules>
<module>sub module </module>
<module> microservice A </module>
<module> microservice B </module>
</modules>
所以我破解,没有太多了解,有时我有不同的消息,但总是编译失败
具体来说,可以使用微服务A和B中子模块的Repositories吗?
感谢您的关注和帮助