dispatcherServletRegistration Spring 启动异常
dispatcherServletRegistration Spring boot exception
请帮忙,我尝试将 Vaadin 放在我的(Spring 启动)服务器上,在设置一个简单示例后,我收到以下错误:
无法注册 class 路径资源 [com/vaadin/flow/spring/SpringBootAutoConfiguration.class] 中定义的 bean 'dispatcherServletRegistration'。已在 class 路径资源 [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class] 中定义了具有该名称的 bean,并且禁用了覆盖。
然后,为了更正错误,我在application.prop中写道:
spring.main.allow-bean 定义覆盖=true
并得到以下错误:
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration 中构造函数的参数 1 需要找不到类型 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' 的 bean。
POM.XML :
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.lopamoko
云状液体
0.0.1-快照
罐子
<name>cloudliquid</name>
<description>Demo project for Spring Boot</description>
<pluginRepositories>
<pluginRepository>
<id>maven-annotation-plugin-repo</id>
<url>http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from com.lopamoko.cloudliquid.repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>ru.leon0399</groupId>
<artifactId>dadata</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-gson</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>0.7.4</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这是我的主要应用程序:
@SpringBootApplication()
@EntityScan("com/lopamoko/cloudliquid/dataModel")
@EnableJpaRepositories(basePackages = "com.lopamoko.cloudliquid.repository")
public class CloudliquidApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(CloudliquidApplication.class, args);
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
FirebaseConfig firebaseConfig = new FirebaseConfig();
firebaseConfig.configurateFirebaseApplication();
}
@Bean
public DadataService dadataService() {
return new DadataServiceImpl();
}
@Bean
public DadataClient dadataClient() {
return Feign.builder()
.client(new OkHttpClient())
.encoder(new GsonEncoder())
.decoder(new GsonDecoder())
.logger(new Slf4jLogger(DadataClient.class))
.logLevel(Logger.Level.FULL)
.target(DadataClient.class, "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address");
}
@Bean
public CustomerDeliveryService customerDeliveryService() {
return new CustomerDeliveryServiceImpl();
}
@Bean
public OrderService orderService() {
return new OrderServiceImpl();
}
@Bean
public YandexService yandexService() {
return new YandexServiceImpl();
}
@Bean
public CategoryService categoryService() {
return new CategoryServiceImpl();
}
@Bean
public ShopService shopService() {
return new ShopServiceImpl();
}
@Bean
public CommentService commentService() {
return new CommentServiceImpl();
}
@Bean
public RatingService ratingService() {
return new RatingServiceImpl();
}
@Bean
public ProductService productService() {
return new ProductServiceImpl();
}
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
}
};
})
和 Vaadin 样本:
@Route("/TestMySelf")
public class MainView extends VerticalLayout {
public MainView() {
Label label = new Label("Hello its CloudLiquid");
}
}
您使用的 vaadin-spring-boot-starter
是什么版本?
来自 this ,它说这是某些旧版本 vaadin-spring-boot-starter
与 Spring Boot 2.1 一起使用时的已知问题,它将在一些较新的版本中得到修复:
We have another working workaround and are also close to finding the
proper fix without the need for the workaround. Regardless which
approach we use first, next week we should have platform releases that
work with Spring Boot 2.1. (v10, v11 and v12)
Sorry for keeping you on hold before being able updating to Spring
Boot 2.1, we should have looked at this earlier - my bad.
然后从发行说明here,它说版本10.1.0支持Spring Boot 2.1。所以我的建议是将 vaadin-spring-boot-starter
至少升级到 10.1.0 或最新版本。
请帮忙,我尝试将 Vaadin 放在我的(Spring 启动)服务器上,在设置一个简单示例后,我收到以下错误:
无法注册 class 路径资源 [com/vaadin/flow/spring/SpringBootAutoConfiguration.class] 中定义的 bean 'dispatcherServletRegistration'。已在 class 路径资源 [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class] 中定义了具有该名称的 bean,并且禁用了覆盖。
然后,为了更正错误,我在application.prop中写道: spring.main.allow-bean 定义覆盖=true
并得到以下错误:
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration 中构造函数的参数 1 需要找不到类型 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' 的 bean。
POM.XML :
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.lopamoko 云状液体 0.0.1-快照 罐子
<name>cloudliquid</name>
<description>Demo project for Spring Boot</description>
<pluginRepositories>
<pluginRepository>
<id>maven-annotation-plugin-repo</id>
<url>http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from com.lopamoko.cloudliquid.repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>ru.leon0399</groupId>
<artifactId>dadata</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-gson</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>0.7.4</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这是我的主要应用程序:
@SpringBootApplication()
@EntityScan("com/lopamoko/cloudliquid/dataModel")
@EnableJpaRepositories(basePackages = "com.lopamoko.cloudliquid.repository")
public class CloudliquidApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(CloudliquidApplication.class, args);
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
FirebaseConfig firebaseConfig = new FirebaseConfig();
firebaseConfig.configurateFirebaseApplication();
}
@Bean
public DadataService dadataService() {
return new DadataServiceImpl();
}
@Bean
public DadataClient dadataClient() {
return Feign.builder()
.client(new OkHttpClient())
.encoder(new GsonEncoder())
.decoder(new GsonDecoder())
.logger(new Slf4jLogger(DadataClient.class))
.logLevel(Logger.Level.FULL)
.target(DadataClient.class, "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address");
}
@Bean
public CustomerDeliveryService customerDeliveryService() {
return new CustomerDeliveryServiceImpl();
}
@Bean
public OrderService orderService() {
return new OrderServiceImpl();
}
@Bean
public YandexService yandexService() {
return new YandexServiceImpl();
}
@Bean
public CategoryService categoryService() {
return new CategoryServiceImpl();
}
@Bean
public ShopService shopService() {
return new ShopServiceImpl();
}
@Bean
public CommentService commentService() {
return new CommentServiceImpl();
}
@Bean
public RatingService ratingService() {
return new RatingServiceImpl();
}
@Bean
public ProductService productService() {
return new ProductServiceImpl();
}
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
}
};
})
和 Vaadin 样本:
@Route("/TestMySelf")
public class MainView extends VerticalLayout {
public MainView() {
Label label = new Label("Hello its CloudLiquid");
}
}
您使用的 vaadin-spring-boot-starter
是什么版本?
来自 this ,它说这是某些旧版本 vaadin-spring-boot-starter
与 Spring Boot 2.1 一起使用时的已知问题,它将在一些较新的版本中得到修复:
We have another working workaround and are also close to finding the proper fix without the need for the workaround. Regardless which approach we use first, next week we should have platform releases that work with Spring Boot 2.1. (v10, v11 and v12)
Sorry for keeping you on hold before being able updating to Spring Boot 2.1, we should have looked at this earlier - my bad.
然后从发行说明here,它说版本10.1.0支持Spring Boot 2.1。所以我的建议是将 vaadin-spring-boot-starter
至少升级到 10.1.0 或最新版本。