关键信息:Description: Failed to auto-configure a DataSource: ‘spring.datasource.url’ is not
specified and no embedded datasource could be auto-configured.Reason: Failed to determine a suitable driver class
Action: Consider the following: If you want an embedded database (H2, HSQL or
Derby), please put it on the classpath. If you have database settings
to be loaded from a particular profile you may need to activate it (no
profiles are currently active)
启动时加载配置文件失败,异常报错,启动失败(网上有些人遇到启动时本不需要加载数据源,却加载了,导致这个问题)
- @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
- public class SpringBootApplication {
- public static void main(String[] args) {
- SpringApplication.run(MySpringBootApplication.class,args);
- }
- }
Ps:exclude = DataSourceAutoConfiguration.class 加上这段代码,去掉数据源
- <build>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <includes>
- <include>*</include>
- <include>*/*</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M1</version>
- <configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.3</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- <encoding>UTF-8</encoding>
- <testIncludes>
- <testInclude>none</testInclude>
- </testIncludes>
- <compilerArguments>
- <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
- </compilerArguments>
- </configuration>
- </plugin>
- </plugins>
- </build>
Ps:可以尝试在pom.xml文件的build标签中加入以上内容