我是SpringBoot的新手。在尝试将此Spring引导webapp部署到外部Tomcat服务器时,我已使用带有嵌入式tomcat.Facing问题的springboot成功执行了一个webapp。 我有吼声错误
无法确定数据库类型为NONE的嵌入式数据库驱动程序类。如果你想要一个嵌入式数据库,请在类路径上放置一个受支持的数据库。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有配置文件处于活动状态)。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': 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.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.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]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:149) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:129) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456) [catalina.jar:7.0.54]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [catalina.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [catalina.jar:7.0.54]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.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]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 26 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 28 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 40 common frames omitted
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_60]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_60]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 41 common frames omitted
2016-03-23 11:55:09.834 INFO 8268 --- [ost-startStop-1] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/classes/, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/aopalliance-1.0.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/classmate-1.1.0.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/hibernate-validator-5.2.4.Final.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jackson-annotations-2.6.5.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jackson-core-2.6.5.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jackson-databind-2.6.5.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jboss-logging-3.3.0.Final.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jcl-over-slf4j-1.7.16.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/jul-to-slf4j-1.7.16.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/log4j-over-slf4j-1.7.16.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/logback-classic-1.1.5.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/logback-core-1.1.5.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/mongo-java-driver-2.13.3.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/mysql-connector-java-5.1.38.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/slf4j-api-1.7.16.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/snakeyaml-1.16.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-aop-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-beans-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-autoconfigure-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-data-mongodb-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-logging-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-security-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-validation-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-boot-starter-web-1.3.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-context-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-core-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-data-commons-1.11.4.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-data-mongodb-1.8.4.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-expression-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-jdbc-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-orm-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-security-config-4.0.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-security-core-4.0.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-security-web-4.0.3.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-tx-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-web-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/spring-webmvc-4.2.5.RELEASE.jar, file:/C:/SATYAJIT/Recrosoft/workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springDemo/WEB-INF/lib/validation-api-1.1.0.Final.jar]
2016-03-23 11:55:09.839 ERROR 8268 --- [ina-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
我正在使用带有jdk7的spring boot 1.3.3。 任何帮助都会很好 - 因为在将Spring引导应用程序作为WAR部署到外部服务器时,任何人都有类似的问题吗?
这是我的档案
的的pom.xml
<project.......>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<groupId>SpringBootDemo</groupId>
<artifactId>SpringBootDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringBootDemo Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
</dependencies>
<build>
<finalName>SpringBootDemo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
ApplicatationStart.java
package com.springDemo;
@Configuration
@ComponentScan(basePackages="com.springDemo")
@EnableAutoConfiguration
@SpringBootApplication
public class ApplicatationStart extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApplicatationStart.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(ApplicatationStart.class, args);
}
}
application.properties
server.contextPath =/springDemo
#for mongo db
spring.data.mongodb.uri=mongodb://localhost/admin
#spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017
# security properties
security.basic.enabled=false
management.security.enabled=false
答案 0 :(得分:1)
关键是spring-boot-starter-security
正在拉动spring-jdbc
依赖关系。这种依赖关系触发DataSourceAutoConfiguration
创建一个DataSource
,因为你没有明确地定义一个它假定在内存中的H2,HSQLDB或Derby。但是,这些不在您的类路径上,因此启动失败。
现在您有2个选项可以解决此问题。第一种是通过将DataSourceAutoConfiguration
添加到exclude
注释中来明确禁用@SpringBootApplication
。
@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)
public class ApplicatationStart extends SpringBootServletInitializer { ... }
专业提示:您还应移除@Configuration
隐含的@ComponentScan
,@EnableAutoConfiguration
和@SpringBootApplication
。
另一个选项是从spring-jdbc
依赖项中排除spring-boot-starter-security
依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<excludes>
<exclude>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</exclude>
</excludes>
</dependency>