这是尝试运行我的Web应用程序时引发的错误:
[INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please …Run Code Online (Sandbox Code Playgroud) spring-boot:run当项目的父POM由于其子项而使用打包模式POM时,是否可以使用Spring Boots Maven插件命令?
我有一个带有"主"POM的多模块maven项目,它是Spring Boot Parent模块的子项.看起来像这样:
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>project</artifactId>
<packaging>pom</packaging>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<relativePath/>
</parent>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.example.module1.Application</start-class>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
这基本上是我们的"主人"POM,每个孩子都使用它作为它的父母.现在我们spring-boot:run要从这个"主"POM所在的工作目录中执行命令.问题是,这会生成一个ClassNotFoundException奇数,因为module1(此类Application所在的位置)包含在POM中并作为模块提及.
使用单个模块maven项目,<packaging>jar</packaging>这将编译并运行Application类,因此Spring-Boot不是在这里工作.
spring-boot-maven-plugin在处理多模块Maven项目时,我需要更改什么才能使其工作或者根本无法使用插件?
旁注:我的应用程序类/模块1将其他模块作为依赖项,因此在回答问题时请记住这一点.任何关于如何改进这一点的建议都非常感谢.