- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在 Java 7(确切版本:jdk1.7.0_60)上运行我的项目,但由于公司范围内的政策更改为升级到 Java 8(版本:jdk1.8.0_73),我已经升级了本地计算机的 JVM到jdk1.8.0_73并在此版本上配置我的项目。
以下是我的项目的事实:
Spring框架版本:4.0.3.RELEASE
Java:jdk1.8.0_73
从那时起,我的应用程序抛出以下异常:
Feb 16, 2016 12:15:14 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#1': Cannot create inner bean 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0' of type [com.asi.core.spring.interceptor.ThrottleRequestInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.asi.v1.ext.api.service.impl.ThrottleService com.asi.core.spring.interceptor.ThrottleRequestInterceptor.throttlerV1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'throttlerV1': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.client.RestTemplate com.asi.v1.ext.api.service.impl.ThrottleService.restTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplate' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.MediaType#3ffc5996' of type [org.springframework.http.MediaType] while setting bean property 'supportedMediaTypes' with key [0]; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.ExpressionInvocationTargetException: A problem occurred when trying to execute method 'forName' on object of type [java.lang.Class]
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:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#1': Cannot create inner bean 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0' of type [com.asi.core.spring.interceptor.ThrottleRequestInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.asi.v1.ext.api.service.impl.ThrottleService com.asi.core.spring.interceptor.ThrottleRequestInterceptor.throttlerV1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'throttlerV1': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.client.RestTemplate com.asi.v1.ext.api.service.impl.ThrottleService.restTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplate' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.MediaType#3ffc5996' of type [org.springframework.http.MediaType] while setting bean property 'supportedMediaTypes' with key [0]; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.ExpressionInvocationTargetException: A problem occurred when trying to execute method 'forName' on object of type [java.lang.Class]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:632)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:470)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1071)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.detectMappedInterceptors(AbstractHandlerMapping.java:221)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.initApplicationContext(AbstractHandlerMapping.java:196)
at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 20 more
这是我的 Spring 配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven/>
<web-services:annotation-driven/>
<web-services:dynamic-wsdl id="productSearch" portTypeName="ProductSearch"
targetNamespace="http://www.asicentral.com/schema/product" locationUri="/productSearchService">
<web-services:xsd location="/WEB-INF/product.xsd"/>
</web-services:dynamic-wsdl>
<web-services:dynamic-wsdl id="loginAPI" portTypeName="LoginAPI"
targetNamespace="http://www.asicentral.com/schema/login" locationUri="/loginAPI">
<web-services:xsd location="/WEB-INF/login.xsd"/>
</web-services:dynamic-wsdl>
<web-services:dynamic-wsdl id="batchAPI" portTypeName="BatchAPI"
targetNamespace="http://www.asicentral.com/schema/batch" locationUri="/batchAPI">
<web-services:xsd location="/WEB-INF/batch.xsd"/>
</web-services:dynamic-wsdl>
<context:component-scan base-package="com.asi"></context:component-scan>
<mvc:interceptors>
<bean class="com.asi.core.spring.interceptor.ThrottleRequestInterceptor" />
</mvc:interceptors>
<cache:annotation-driven />
<import resource="v1.xml"/>
<!-- When more versions are listed load version specific xml config -->
<import resource="v2.xml"/>
<import resource="v3.xml"/>
<bean id="headerHandler" class="com.asi.v1.service.resource.util.ExternalApiHeaderHandler" />
<bean id="ExternalApiApplicationContextProvider" class="com.asi.core.spring.config.provider.ExternalApiApplicationContextProvider"></bean>
<bean id="environmentConfigurator" class="com.asi.ext.api.config.EnvironmentConfigurator">
<property name="env" value="${Ext.env}"></property>
<property name="lookupRestTemplate" ref="restTemplate"></property>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml"/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
<context:property-placeholder location="classpath:${Ext.env}-environment.properties, classpath:velocity-import*.properties, classpath:radar-version.properties" order="1"/>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml"/>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
</list>
</property>
</bean>
<bean id="dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="jdbcUrl" value="jdbc:sqlserver://${db.velocity.host}:${db.velocity.port};databaseName=${db.velocity.database}" />
<property name="user" value="${db.velocity.username}" />
<property name="password" value="${db.velocity.password}" />
<!-- these are C3P0 properties -->
<property name="acquireIncrement" value="1" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="300" />
</bean>
<bean id="hibernate3AnnotatedSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.asi.ext.api.dao.ExternalAPILogger</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
</bean>
<bean id="logDAO" class="com.asi.ext.api.dao.ExternalApiLoggerImpl">
<property name="sessionFactory" ref="hibernate3AnnotatedSessionFactory" />
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg value="application" />
<constructor-arg value="json" />
<constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/>
</bean>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter ">
<constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/>
</bean>
</list>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>error</value>
</property>
</bean>
</beans>
而 v1、v2 和 v3.xml 导入适用于不同版本的 bean。例如,下面只是 v1.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="loginServiceV1" class="com.asi.v1.ext.api.service.impl.LoginServiceImpl">
<property name="restTemplate" ref="restTemplate" />
<property name="loginAPIUrl" value="${ws.api.login}" />
<property name="authorizationKey" value="${ws.api.login.doorman.key}" />
<property name="authorizationScheme" value="${ws.api.login.doorman.auth.scheme}" />
<property name="grantTypeKey" value="${ws.api.login.doorman.auth.grant_type.key}" />
<property name="grantTypeValue" value="${ws.api.login.doorman.auth.grant_type.value}" />
<property name="appCodeKey" value="${ws.api.login.doorman.auth.app_code.key}" />
<property name="appCodeValue" value="${ws.api.login.doorman.auth.app_code.value}" />
<property name="appVersionKey" value="${ws.api.login.doorman.auth.app_version.key}" />
<property name="appVersionValue" value="${ws.api.login.doorman.auth.app_version.value}" />
</bean>
<bean id="batchServiceV1" class="com.asi.v1.ext.api.service.impl.BatchServiceImpl">
<property name="restTemplate" ref="restTemplate" />
<property name="createBatchURL" value="${ws.api.batch.create}" />
<property name="finalizeBatchURL" value="${ws.api.batch.finalize}" />
</bean>
<bean id="productServiceClientV1" class="com.asi.v1.service.product.client.ProductClient">
<property name="productSearchUrl" value="${ws.api.product.import}" />
<property name="scheme" value="${ws.api.authorization.scheme}" />
</bean>
<bean id="throttlerV1" class="com.asi.v1.ext.api.service.impl.ThrottleService">
<property name="radarLoginService" value="${ws.api.throttle.radar.validate.token.url}" />
<property name="throttleRequest" value="${ws.api.throttle.required}" />
<property name="maximumRequests" value="${ws.api.throttle.maximum.requests}" />
<property name="maximumWaitCalendarField" value="${ws.api.throttle.wait.time.field}" />
<property name="maximumWaitHours" value="${ws.api.throttle.wait.time}" />
<property name="restTemplate" ref="restTemplate"/>
</bean>
<!-- <bean id="loginService" class="com.asi.v1.service.resource.LoginService">
<property name="loginAPIUrl" value="${ws.api.login}"></property>
</bean> -->
<!-- <bean id="lookupDataStore" class="com.asi.v1.ext.api.product.transformers.ProductDataStore">
<property name="lookupRestTemplate" ref="restTemplate"/>
<property name="lookupConverter" ref="jsonlookupConvertor" />
</bean>
<bean id="jsonlookupConvertor" class="com.asi.v1.ext.api.util.JsonToLookupTableConverter">
<property name="lookupRestTemplate" ref="restTemplate"/>
</bean> -->
<bean id="lookupValuesClientV1" class="com.asi.v1.service.product.client.LookupValuesClient">
<property name="lookupRestTemplate" ref="restTemplate"/>
<property name="lookupColorURL" value="${lookup.color.url}"></property>
<property name="lookupSizeURL" value="${lookup.sizes.url}"></property>
<property name="lookupMaterialURL" value="${lookup.material.url}"></property>
<property name="lookupcriteriaAttributeURL" value="${lookup.sizes.criteria.url}"></property>
<property name="originLookupURL" value="${lookup.orgin.url}"></property>
<property name="lookupCategoryURL" value="${lookup.product.categories.url}"></property>
<property name="lookupArtworkURL" value="${lookup.imprint.artwork.url}"></property>
<property name="lookupImprintURL" value="${lookup.imprint.url}"></property>
<property name="lookupTradeNameURL" value="${lookup.product.trade.names.url}"></property>
<property name="lookupShapeURL" value="${lookup.product.shapes.url}"></property>
<property name="lookupPackageURL" value="${lookup.packaging.url}"></property>
</bean>
<bean id="lookupParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.LookupParser">
<!-- <property name="lookupClient" ref="lookupValuesClient"/> -->
<!-- <property name="imprintParser" ref="imprintMethodParser"/> -->
</bean>
<bean id="criteriasParser" class="com.asi.v1.ext.api.integration.lookup.parser.CriteriaSetParser">
<!-- <property name="productLookupParser" ref="lookupParser"/> -->
</bean>
<bean id="productConfigurationParser" class="com.asi.v1.ext.api.integration.lookup.parser.ProductConfigurationsParser">
<property name="productLookupParser" ref="lookupParser"/>
</bean>
<bean id="configurationParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.ConfigurationsParser">
<!-- <property name="productLookupParser" ref="lookupParser"/> -->
</bean>
<bean id="imprintMethodParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.ImprintParser">
<!-- <property name="criteriaLookupParser" ref="criteriasParser"/>
<property name="lookupsParser" ref="lookupParser"/> -->
</bean>
<bean id="productServiceV1" class="com.asi.v1.ext.api.service.impl.ProductServiceImpl">
</bean>
<bean id="productRepoV1" class="com.asi.v1.core.repo.product.ProductRepo">
<!-- <property name="productClient" ref="productServiceClient"/> -->
<!-- <property name="productConfiguration" ref="productConfigurationParser"/> -->
<!-- <property name="configurationParser" ref="configurationParser"/> -->
<!-- <property name="imprintParser" ref="imprintMethodParser"/> -->
<!-- <property name="productRestTemplate" ref="restTemplate"/> -->
<property name="productImportURL" value="${ws.api.product.import}"></property>
<property name="batchProcessingURL" value="${lookup.batch.processing}"></property>
<!-- <property name="lookupDataStore" ref="lookupDataStore" /> -->
<!-- <property name="lookupsParser" ref="lookupParser"/> -->
</bean>
<!-- To enable @RequestMapping process on type level and method level -->
<bean id="productDetailV1" class="com.asi.v1.service.product.client.vo.ProductDetail"/>
</beans>
这个问题从来没有出现过,直到我使用 Java 7 版本,当我将其切换到 Java 8 时,我才看到这个异常。由于此编辑器的限制,我无法粘贴整个异常日志。如果需要,将粘贴在评论中。
谁能帮我解决这个问题吗?
最佳答案
尝试 value="java.nio.charset.StandardCharsets.UTF_8"
而不是 value="#{T(java.nio.charset.Charset).forName('UTF- 8')}"
。您还需要命名您的参数,否则 Spring 将无法实例化 MediaType,因为存在多个具有 3 个参数的构造函数。
您可以尝试以下代码:
<bean class="org.springframework.http.MediaType" >
<constructor-arg name="type" value="application" />
<constructor-arg name="subtype" value="json" />
<constructor-arg name="charset" value="#{T(java.nio.charset.StandardCharsets).UTF_8}"/>
</bean>
关于java - spring Autowiring 依赖项注入(inject)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35439242/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!