Spring 找不到存储库类require bean entityManagerFactory

Spring 找不到存储库类require bean entityManagerFactory,spring,hibernate,maven,spring-boot,jpa,Spring,Hibernate,Maven,Spring Boot,Jpa,我正在中制作angular+spring应用程序,并试图将其部署在同一台服务器上。当我单独创建后端时,它运行良好,整个过程都正常。但是,当我在spring项目中复制angular项目并在pom.xml中进行配置,更新maven并尝试运行该项目时,它开始给我以下错误 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \

我正在中制作angular+spring应用程序,并试图将其部署在同一台服务器上。当我单独创建后端时,它运行良好,整个过程都正常。但是,当我在spring项目中复制angular项目并在pom.xml中进行配置,更新maven并尝试运行该项目时,它开始给我以下错误

 .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-24 16:13:29.074  INFO 3136 --- [           main] 
com.accounts.rtgsneft.Application        : Starting Application on HO-W- 
Ankushpc with PID 3136 (D:\Rocky\workspaces\acounts-projects\rtgs-neft- 
v1.0\target\classes started by Rocky in D:\Rocky\workspaces\acounts- 
projects\rtgs-neft-v1.0)
2019-09-24 16:13:29.076  INFO 3136 --- [           main] 
com.accounts.rtgsneft.Application        : No active profile set, falling 
back to default profiles: default
2019-09-24 16:13:29.530  INFO 3136 --- [           main] 
.s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data 
repositories in DEFAULT mode.
2019-09-24 16:13:29.584  INFO 3136 --- [           main] . 
s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository 
scanning in 48ms. Found 4 repository interfaces.
2019-09-24 16:13:29.910  INFO 3136 --- [           main] 
trationDelegate$BeanPostProcessorChecker : Bean 
'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$3c9c44bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-24 16:13:30.143  INFO 3136 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8086 (http)
2019-09-24 16:13:30.160  INFO 3136 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-09-24 16:13:30.160  INFO 3136 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-24 16:13:30.264  INFO 3136 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-09-24 16:13:30.264  INFO 3136 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1158 ms
2019-09-24 16:13:30.399  WARN 3136 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'beneficiaryController': Unsatisfied dependency expressed through field 'beneficiaryService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'beneficiaryMasterServiceImpl': Unsatisfied dependency expressed through field 'beneficiaryRepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beneficiaryMasterRepository': Cannot create inner bean '(inner bean)#3ac04654' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3ac04654': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2019-09-24 16:13:30.402  INFO 3136 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-09-24 16:13:30.416  INFO 3136 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run 
your application with 'debug' enabled.
2019-09-24 16:13:30.465 ERROR 3136 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

 ***************************
 APPLICATION FAILED TO START
 ***************************

Description:

Field beneficiaryRepo in 
com.accounts.rtgsneft.service.BeneficiaryMasterServiceImpl 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.
我已经在stack上尝试了所有的解决方案,但没有一个有效

以下是我尝试过的解决方案:

这是我调试时尝试的解决方案

我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.7.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.accounts.rtgsneft</groupId>
<artifactId>rtgsneft</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rtgsneft</name>
<description>Gold's Gym Account department rtgs neft software</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/src/main/resources/static/</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/main/rtgs-neft/dist/rtgs-neft</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

4.0.0
org.springframework.boot
spring启动程序父级
2.1.7.发布
com.accounts.rtgsneft
rtgsneft
0.0.1-快照
rtgsneft
Gold的健身房会计部rtgs neft软件
1.8
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
弹簧启动启动器数据rest
org.springframework.boot
弹簧靴启动器jdbc
mysql
mysql连接器java
运行时
org.projectlombok
龙目
真的
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
springbootmaven插件
maven资源插件
复制资源
验证
复制资源
${basedir}/src/main/resources/static/
${basedir}/src/main/rtgs-neft/dist/rtgs-neft
我的受益人控制器

package com.accounts.rtgsneft.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.accounts.rtgsneft.model.BeneficiaryMaster;
import com.accounts.rtgsneft.service.BeneficiaryMasterService;

/**
* @author Rocky
*
*/
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("beneficiary")
public class BeneficiaryController {

@Autowired
BeneficiaryMasterService beneficiaryService;

@GetMapping("all-beneficiary")
public ResponseEntity<?> getBeneficiaries() {
    List<BeneficiaryMaster> beneficiaries = beneficiaryService.gettingBeneficiaries();
    return new ResponseEntity<>(beneficiaries, HttpStatus.OK);
}

@PostMapping("new-beneficiary")
public ResponseEntity<?> postBeneficiary(@RequestBody BeneficiaryMaster beneficiary) {
    boolean beneficiaryRegistered = beneficiaryService.registerBeneficiary(beneficiary);
    return new ResponseEntity<>(beneficiaryRegistered, HttpStatus.OK);
}

@PostMapping("single-beneficiary")
public ResponseEntity<?> selectedBeneficiary(@RequestBody BeneficiaryMaster beneficiaryOBJ) {
    BeneficiaryMaster beneficiary = beneficiaryService.getBeneficiary(beneficiaryOBJ.getAccountNumber());
    return new ResponseEntity<>(beneficiary, HttpStatus.OK);
}
}
package com.accounts.rtgsneft.controller;
导入java.util.List;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.http.HttpStatus;
导入org.springframework.http.ResponseEntity;
导入org.springframework.web.bind.annotation.CrossOrigin;
导入org.springframework.web.bind.annotation.GetMapping;
导入org.springframework.web.bind.annotation.PostMapping;
导入org.springframework.web.bind.annotation.RequestBody;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RestController;
导入com.accounts.rtgsneft.model.受益人主服务器;
导入com.accounts.rtgsneft.service.benginiarymasterservice;
/**
*@作者洛基
*
*/
@交叉原点(原点=“*”,最大值=3600)
@RestController
@请求映射(“受益人”)
公共类受益人控制人{
@自动连线
受益人服务受益人服务;
@GetMapping(“所有受益人”)
公众责任{
列表受益人=受益人服务。获取受益人();
返回新的响应(受益人,HttpStatus.OK);
}
@邮购(“新受益人”)
公共响应后受益人(@RequestBody受益人主受益人){
布尔值受益人登记=受益人服务登记簿受益人(受益人);
返回新的响应状态(受益人已注册,HttpStatus.OK);
}
@邮购(“单一受益人”)
公共响应选定受益人(@RequestBody受益人主受益人YOBJ){
受益人主受益人=受益人服务.get受益人(受益人YOBJ.getAccountNumber());
返回新的响应状态(受益人,HttpStatus.OK);
}
}
我的受益人MasterService.java

package com.accounts.rtgsneft.service;

import java.util.List;

import com.accounts.rtgsneft.model.BeneficiaryMaster;
public interface BeneficiaryMasterService {
List<BeneficiaryMaster> gettingBeneficiaries();
boolean registerBeneficiary(BeneficiaryMaster beneficiary);
BeneficiaryMaster getBeneficiary(Long accountNumber);
}
package com.accounts.rtgsneft.service;
导入java.util.List;
导入com.accounts.rtgsneft.model.受益人主服务器;
公共接口受益者管理服务{
列表获取受益人();
布尔寄存器益处(受益人主受益人);
受益人主收款人(长账号);
}
我的受益人MasterServiceImpl.java

package com.accounts.rtgsneft.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.accounts.rtgsneft.model.BeneficiaryMaster;
import com.accounts.rtgsneft.repos.BeneficiaryMasterRepository;
@Service
public class BeneficiaryMasterServiceImpl implements BeneficiaryMasterService {

@Autowired
BeneficiaryMasterRepository beneficiaryRepo;

@Override
public List<BeneficiaryMaster> gettingBeneficiaries() {     
    return beneficiaryRepo.findAll();
}

@Override
public boolean registerBeneficiary(BeneficiaryMaster beneficiary) {

    boolean benficiaryStatusFlag = false;
    BeneficiaryMaster benficiaryStatus= beneficiaryRepo.save(beneficiary);
    if(benficiaryStatus != null ) {
        benficiaryStatusFlag = true;
    }
    return benficiaryStatusFlag;
}

@Override
public BeneficiaryMaster getBeneficiary(Long accountNumber) {
    return beneficiaryRepo.getOne(accountNumber);
}
}
package com.accounts.rtgsneft.service;
导入java.util.List;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.stereotype.Service;
导入com.accounts.rtgsneft.model.受益人主服务器;
导入com.accounts.rtgsneft.repos.受益人存储库;
@服务
public类benginiarymasterserviceinpl实现benginiarymasterservice{
@自动连线
受益人存储库受益人报告;
@凌驾
公共列表获取受益人(){
返回受益人repo.findAll();
}
@凌驾
公共布尔寄存器好处(受益人主受益人){
布尔benficiaryStatusFlag=false;
受益人主管benficiaryStatus=受益人报告保存(受益人);
if(benficiaryStatus!=null){
benficiaryStatusFlag=真;
}
返回benficiaryStatusFlag;
}
@凌驾
公共受益人主受益人(长账号){
返回受益人REPO.getOne(账号);
}
}
我的受益人MasterRepository.java

package com.accounts.rtgsneft.repos;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.accounts.rtgsneft.model.BeneficiaryMaster;
@Repository
public interface BeneficiaryMasterRepository extends 
JpaRepository<BeneficiaryMaster, Long> {}
package com.accounts.rtgsneft.repos;
导入org.springframework.data.jpa.repository.JpaRepository;
导入org.springframework.stereotype.Repository;
导入com.accounts.rtgsneft.model.受益人主服务器;
@存储库
公共接口受益者存储库扩展
JpaRepository{}
我希望这些数据足以找出问题所在

如果有其他解决方案,请向我推荐。 我用的是Spring2.17
我想在tomcat中部署应用程序war文件,在此之前,我必须测试它以检查它是否仍在工作。

Spring Data JPA默认情况下查找名为EntityManagerFactory的EntityManagerFactory。查看EnableJpaRepositories的Javadoc的这一部分或Spring数据JPA文档的表2.1