启动spring启动应用程序时出错,couchbase错误创建名为';tomcatEmbeddedServletContainerFactory';
我不熟悉spring boot和couchbase。我编写了一个简单的应用程序,试图连接到我的couchbase bucket,但在启动时,它却给我带来了错误启动spring启动应用程序时出错,couchbase错误创建名为';tomcatEmbeddedServletContainerFactory';,tomcat,spring-boot,java-8,couchbase,Tomcat,Spring Boot,Java 8,Couchbase,我不熟悉spring boot和couchbase。我编写了一个简单的应用程序,试图连接到我的couchbase bucket,但在启动时,它却给我带来了错误 org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$$EnhancerBySpringCGLIB$$6f4ff8c5]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$$EnhancerBySpringCGLIB$$6f4ff8c5.<init>()
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[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.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:773) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:368) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1190) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1179) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
org.springframework.context.ApplicationContextException:无法启动嵌入式容器;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“tomcatEmbeddedServletContainerFactory”的bean时出错,该bean在类路径资源[org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]中定义:初始化bean失败;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration”的bean时出错:bean实例化失败;嵌套异常为org.springframework.beans.beanstantiationException:未能实例化[org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$$EnhancerBySpringCGLIB$$6f4ff8c5]:未找到默认构造函数;嵌套的异常是java.lang.NoSuchMethodException:org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$$EnhancerBySpringCGLIB$$6f4ff8c5。()
在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)~[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)~[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:773)[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
位于org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:368)[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:1190)[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:1179)[spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
我的班级看起来像这样
@Configuration
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class ShippingFeesApplication {
@Autowired
public CouchBaseBasicRepository<ShippingFeesParams> repo;
@Autowired
public CouchBaseConfiguration config;
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(ShippingFeesApplication.class, args);
ctx.close();
}
@Bean
CommandLineRunner commandLineRunner(){
return args -> { ShippingFeesParams singleObject = new ShippingFeesParams();
String key = "GUS/ANDROID/10001";
singleObject.setId(key);
singleObject.setAddOnThreshold(25.00);
singleObject.setCreatedDate(Calendar.getInstance().getTime());
singleObject.setDeliveryType(1);
singleObject.setFreeShippingThreshold(49.99);
singleObject.setLastModifiedDate(Calendar.getInstance().getTime());
AdditionShippingRules rules = new AdditionShippingRules();
rules.setBaseShippingPrice(9.95);
rules.setHeavyWeightShippingPrice(14.99);
rules.setStoreId("10001");
singleObject.setAdditionRules(rules);
repo.save(singleObject);
repo.findOne(key);
Iterable<ShippingFeesParams> shippingFees = repo.findAll();
shippingFees.forEach((shipping)-> log.info(shipping.toString()));
};
}
}
@配置
@SpringBoot应用程序
@启用自动配置
@组件扫描
公共类托运费应用{
@自动连线
公共CouchbaseBasicResposition回购;
@自动连线
公共CouchBaseConfiguration配置;
公共静态void main(字符串[]args){
ConfigurableApplicationContext ctx=SpringApplication.run(ShippingFeesApplication.class,args);
ctx.close();
}
@豆子
CommandLineRunner CommandLineRunner(){
返回args->{ShippingFeesParams singleObject=new ShippingFeesParams();
String key=“GUS/ANDROID/10001”;
setId(key);
singleObject.setAddOnThreshold(25.00);
setCreatedDate(Calendar.getInstance().getTime());
singleObject.setDeliveryType(1);
singleObject.setFreeShippingThreshold(49.99);
setLastModifiedDate(Calendar.getInstance().getTime());
AdditionShippingRules规则=新的AdditionShippingRules();
规则.交货价格(9.95);
规则。设定重量级装运价格(14.99);
规则。设置存储区(“10001”);
singleObject.setAdditionRules(规则);
repo.save(单对象);
回购金融工具(关键);
Iterable shippingFees=repo.findAll();
shippingFees.forEach((shipping)->log.info(shipping.toString());
};
}
}
沙发床
@Component
public interface CouchBaseBasicRepository<BaseDataType extends CouchBaseDocument> extends CrudRepository<BaseDataType, String> {
}
@组件
公共接口CouchbaseBasicResposition扩展了CrudResposition{
}
Couchbase配置
@Configuration
@EnableAutoConfiguration
@EnableCouchbaseRepositories
public class CouchBaseConfiguration extends AbstractCouchbaseConfiguration {
@Value("${couchbase.bucket.name:shiping_fees_config}")
private String bucketName;
@Value("${couchbase.bucket.password}")
private String password;
@Value("${couchbase.bootstrap-hosts:127.0.0.1}")
private String ip;
@Override
protected List<String> bootstrapHosts() {
return Arrays.asList(ip);
}
@Override
public String getBucketName() {
return bucketName;
}
@Override
protected String getBucketPassword() {
return password;
}
}
@配置
@启用自动配置
@EnableCouchbaseRepositories
公共类CouchBaseConfiguration扩展了AbstractCouchbaseConfiguration{
@值(${couchbase.bucket.name:shipping\u fees\u config})
私有字符串bucketName;
@值(${couchbase.bucket.password}”)
私有字符串密码;
@值(${couchbase.bootstrap主机:127.0.0.1}”)
私有字符串ip;
@凌驾
受保护列表bootstrapHosts(){
返回数组.asList(ip);
}
@凌驾
公共字符串getBucketName(){
返回bucketName;
}
@凌驾
受保护的字符串getBucketPassword(){
返回密码;
}
}
这是我的pom文件
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
<dependency>
<groupId>com.staples.gp</groupId>
<artifactId>domain-shipping</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.staples.gp</groupId>
<artifactId>api-common</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>commons-compiler</artifactId>
<version>2.7.8</version>
</dependency>
</dependencies>
org.springframework.boot
弹簧靴起动器执行器
org.springframework.boot
弹簧启动机tomcat
假如
org.springframework.cloud
春云起动器尤里卡
org.springframework.cloud
春云
org.springframework.boot
spring boot starter数据库
com.staples.gp
域传送
0.0.1-快照
com.staples.gp
api通用
0.1.1
org.springframework.boot
弹簧启动安全
org.springframework.boot
弹簧起动试验
测试
org.springframework.restdocs
SpringRestMVC
测试
commons httpclient
commons httpclient
3.1
org.codehaus.janino
@Configuration
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
@SpringBootApplication