当前位置: 首页 > 知识库问答 >
问题:

添加模块描述符时,没有名为“entityManagerFactory”的bean可用

鲜于德泽
2023-03-14

我想开发一个模块化的应用程序,使用MySql数据库,Java11和Spring启动。在我添加模块描述符之前,这个应用程序运行得非常好;所以我只能猜测我在module-info.java中丢失了一些东西,但我不知道它是什么。我感谢任何帮助。这是我的密码

波姆。xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <java.version>11</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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

应用yml

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/modules?serverTimezone=UTC
    username: modulesAdmin
    password: modules
  jpa:
    hibernate:
      ddl-auto: create-drop
    show-sql: true
    properties:
      hibernate.format_sql: true

module-info.java

    requires java.persistence;
    requires spring.context;
    requires spring.beans;
    requires spring.data.jpa;
    requires spring.data.commons;
    requires spring.web;
    requires spring.boot;
    requires spring.boot.autoconfigure;

    opens com.jamsws.demojpa to spring.core;

    exports com.jamsws.demojpa to spring.beans, spring.context;
    exports com.jamsws.demojpa.resource to spring.beans;

使用者JAVA

@Entity
public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String name;
    private String teamName;
    private Integer salary;

    public User() {
    }

    public User(String name, String teamName, Integer salary) {
        this.name = name;
        this.teamName = teamName;
        this.salary = salary;
    }

    // getters and setters
}

UsersRepository.java

@Repository
public interface UsersRepository extends JpaRepository<User, Integer> {
}

用户资源。JAVA

@RestController
@RequestMapping(value = "rest/users")
public class UserResources {

    @Autowired
    private UsersRepository usersRepository;

    @PostMapping(value = "/load")
    public List<User> persist(@RequestBody final User user) {
        usersRepository.save(user);
        return usersRepository.findAll();
    }
}

演示应用程序。JAVA

@SpringBootApplication
@EntityScan(basePackages = "com.jamsws.demojpa.model")
@EnableJpaRepositories(basePackages = "com.jamsws.demojpa.repository")
public class DemojpaApplication {

    public static void main(String[] args) {

        SpringApplication.run(DemojpaApplication.class, args);

    }

}

错误跟踪

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:982) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:992) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.startup.Tomcat.stop(Tomcat.java:478) ~[tomcat-embed-core-9.0.36.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:273) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:331) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:148) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at demojpa/com.jamsws.demojpa.DemojpaApplication.main(DemojpaApplication.java:15) ~[classes/:na]
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:267) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5431) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
    ... 23 common frames omitted
Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[na:na]
    at java.base/java.lang.Class.getMethodsRecursive(Class.java:3307) ~[na:na]
    at java.base/java.lang.Class.getMethod0(Class.java:3293) ~[na:na]
    at java.base/java.lang.Class.getMethod(Class.java:2106) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc(WebappClassLoaderBase.java:1697) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:1619) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:1555) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:449) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    ... 31 common frames omitted
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:72) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) ~[tomcat-embed-core-9.0.36.jar:na]
    ... 41 common frames omitted

2020-07-19 19:51:17.437 ERROR 10199 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during stop

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during stop
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:982) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:992) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.startup.Tomcat.stop(Tomcat.java:478) ~[tomcat-embed-core-9.0.36.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:273) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:331) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:148) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at spring.boot@2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar:na]
    at demojpa/com.jamsws.demojpa.DemojpaApplication.main(DemojpaApplication.java:15) ~[classes/:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during stop
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:990) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
    at org.apache.tomcat.embed.core@9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
    ... 16 common frames omitted

2020-07-19 19:51:17.441  INFO 10199 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-19 19:51:17.469 ERROR 10199 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Field usersRepository in com.jamsws.demojpa.resource.UserResources 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.

编辑:根据@Naman的建议,我添加了一个需要java。sql 到模块描述符文件,这有助于解决“没有名为'entityManagerFactory'的bean可用”的问题

2020-07-20 06:57:54.679  INFO 21643 --- [           main] com.jamsws.demojpa.DemojpaApplication    : Starting DemojpaApplication on anderson-ubuntu with PID 21643 (/home/anderson/Documents/JavaApps/PracticeProjects/demojpa/target/classes started by anderson in /home/anderson/Documents/JavaApps/PracticeProjects/demojpa)
2020-07-20 06:57:54.681  INFO 21643 --- [           main] com.jamsws.demojpa.DemojpaApplication    : No active profile set, falling back to default profiles: default
2020-07-20 06:57:54.973  INFO 21643 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-07-20 06:57:54.996  INFO 21643 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 20ms. Found 1 JPA repository interfaces.
2020-07-20 06:57:55.272  INFO 21643 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-07-20 06:57:55.276  INFO 21643 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-07-20 06:57:55.276  INFO 21643 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-07-20 06:57:55.295  INFO 21643 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-07-20 06:57:55.295  INFO 21643 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 579 ms
2020-07-20 06:57:55.327  WARN 21643 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userResources': Unsatisfied dependency expressed through field 'usersRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersRepository' defined in com.jamsws.demojpa.repository.UsersRepository defined in @EnableJpaRepositories declared on DemojpaApplication: Cannot create inner bean '(inner bean)#5c080ef3' 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)#5c080ef3': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2020-07-20 06:57:55.328  INFO 21643 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-07-20 06:57:55.338  INFO 21643 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-20 06:57:55.370 ERROR 21643 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Field usersRepository in com.jamsws.demojpa.resource.UserResources 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.


Process finished with exit code 1


共有2个答案

佟阳焱
2023-03-14

我已经检查了你的堆栈跟踪。你能试试下面的步骤吗

  1. 从UserRepository中删除@Repository注释。java
  2. 仅当UserRepository可用时,才从DemoJPA应用程序中删除@EnableJpaRepositories。java位于主DemoJPA应用程序的子包中。爪哇
雷曜灿
2023-03-14

异常的主要原因似乎是

Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException

同时,在你的问题中提到“在我添加模块描述符之前,应用程序工作得非常好”,似乎表明在引入模块信息之前。java,您的应用程序必须使用类路径,在该路径中,它能够通过可传递依赖项找到上面提到的类。

1另一个方面是,您的应用程序不直接需要这个类,否则您将面临编译时错误,声明导入是不可识别的。

这归结为您在应用程序描述符中提到的模块依赖关系,因此其中一个或多个需要java。sql。SQLException现在出现在modulepath上,但它本身没有明确指定它(在自动模块的情况下很可能)。您需要确定您需要的模块中的哪些模块可能需要特定的类以实现长期解决方案。

1一种方法是,将其报告给库/模块所有者,并要求他们定义明确的依赖关系。这可能需要您等待它们自行升级,然后使用升级版本。在这种情况下,您可以在应用程序中添加参数,直到出现升级

--add-modules=java.sql 

另一个可能是您的应用程序本身在运行时需要java.sql模块,并且库只是在您显式声明时使用它。在这种情况下,解决方案是将以下内容添加到您的module-info.java文件中:

requires java.sql
 类似资料:
  • 我创建了一个Spring Boot应用程序,并使用我想要执行的方法创建了一个类。将项目部署为war文件时,我从stacktrac中获取错误。我想从类TennisExecitor中运行该方法。 没有名为'entityManagerFactory'的bean可用 创建名为'(内部bean)#366583f9'的bean时出错:设置构造函数参数时无法解析对bean'entityManagerFactor

  • 我正在尝试开发一个新的批与Spring批和jpa。当我尝试启动它时,我收到错误"嵌套异常是org.springframework.beans.factory.NoSuchBean定义异常:没有名为'entityManagerFactory'可用的bean" 我的pom.xml 我的数据源配置类: 我的存储库类: 我的实体类: pplication.properties: 如果我尝试启动应用程序,我

  • 我正在开发一个新的应用程序(对我来说),我在启动时收到了无bean“entityManagerFactory”可用错误。其他经历过这种情况的人表示,如果我正确定义了数据源,这种情况就不会发生。让我困惑的是,Spring Boot/JPA或Flyway(我也在使用)坚持将特定的属性名称用于您的一个数据源。我不知道如果你有一个以上的人会怎么处理。我需要更改我们的申请。属性文件,以便从环境变量中获取值,

  • 我正在开发一个小应用程序,只是为了自己尝试Spring Boot。它有五个不同的模块(eclipse项目): 模型——包含实体类、DTO和映射器以在它们之间切换 数据--包含存储库 服务——包含服务及其实现 reserve management--包含预订控制器和spring应用程序本身 人员管理-包含人员数据的控制器和Spring应用程序本身 如果我启动这两个应用中的任何一个,它们都可以正常运行

  • 请求处理失败;嵌套的异常是org。springframework。豆。工厂NoSuchBeanDefinitionException:没有名为“transactionManager”的bean可用:没有为限定符“transactionManager”找到匹配的transactionManager bean-既没有限定符匹配,也没有bean名称匹配! 客户请求。JAVA 客户控制器 顾客道 spri

  • 问题内容: 我在尝试连接到MySQL数据库时遇到的问题。我还提供了我已使用的数据库设置。 数据库设置:: 非常感谢您的帮助 !! 问题答案: 看来你没有安装python mysql软件包,请尝试: 或如果未使用虚拟环境(在* nix主机上):