Spring mvc 弹簧靴不工作
我不熟悉弹簧靴 我有一个样品 pom.xmlSpring mvc 弹簧靴不工作,spring-mvc,spring-boot,spring-web,Spring Mvc,Spring Boot,Spring Web,我不熟悉弹簧靴 我有一个样品 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apa
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>0.5.0.M4</version>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable JAR -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- Allow access to Spring milestones and snapshots -->
<!-- (you don't need this if you are using anything after 0.5.0.M2) -->
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.springsource.org/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.springsource.org/milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.springsource.org/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.springsource.org/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
当我运行它时,会引发下面的异常
Exception in thread "main" 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.context.embedded.properties.ServerProperties': Could not bind properties; nested exception is
Exception in thread "main" 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.context.embedded.properties.ServerProperties': Could not bind properties; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Cannot access indexed value in property referenced in indexed property path 'compression[min-response-size]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Bean property 'compression[min-response-size]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:179)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:138)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext.refresh(AnnotationConfigEmbeddedWebApplicationContext.java:193)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:514)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:281)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:697)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:686)
at bootSample.SampleController.main(SampleController.java:18)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.embedded.properties.ServerProperties': Could not bind properties; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Cannot access indexed value in property referenced in indexed property path 'compression[min-response-size]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Bean property 'compression[min-response-size]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessAfterInitialization(ConfigurationPropertiesBindingPostProcessor.java:314)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessAfterInitialization(ConfigurationPropertiesBindingPostProcessor.java:279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:421)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:467)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:456)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1063)
at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.getCustomizers(EmbeddedServletContainerCustomizerBeanPostProcessor.java:75)
at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1499)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 15 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Cannot access indexed value in property referenced in indexed property path 'compression[min-response-size]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Bean property 'compression[min-response-size]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:939)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:915)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82)
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:730)
at org.springframework.validation.DataBinder.doBind(DataBinder.java:626)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:78)
at org.springframework.validation.DataBinder.bind(DataBinder.java:611)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:232)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:204)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessAfterInitialization(ConfigurationPropertiesBindingPostProcessor.java:311)
... 33 more
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'compression[min-response-size]' of bean class [org.springframework.boot.context.embedded.properties.ServerProperties]: Bean property 'compression[min-response-size]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:718)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:936)
... 42 more
属性文件:
server.compression.enabled: true
server.compression.min-response-size: 1
我认为有两件事可能是问题所在 1.您使用的springboot版本非常旧,当前版本为1.3,不需要任何里程碑
2.您正在使用的服务器的属性可能有问题,请尝试删除它或发布完整的属性文件,以便我们提供帮助。添加完整的堆栈跟踪请立即添加完整的错误日志看起来您的属性文件有问题。你可以添加它吗?你正在使用一些非常旧版本的spring boot。这甚至是一个里程碑。您应该更新到某个完全稳定的版本。您可以使用或Spring工具套件。
server.compression.enabled: true
server.compression.min-response-size: 1