简体   繁体   English

找不到类 org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

[英]Cannot find class org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

we have upgraded our Project Spring Version from 3.1.2.RELEASE to 4.3.25.RELEASE .我们已将 Project Spring 版本从3.1.2.RELEASE升级到4.3.25.RELEASE

I didn't found any Code related Errors.我没有发现任何与代码相关的错误。 But Junit Test cases are failing by throwing below Error但是 Junit 测试用例因抛出以下错误而失败

Cannot find class [org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer找不到类 [org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

Error Log错误日志

Tests run: 10, Failures: 0, Errors: 10, Skipped: 0, Time elapsed: 3.979 sec <<< FAILURE!
testMergeInProgressStatus(com.perceptive.portal.idm.domain.AccountTest)  Time elapsed: 0.021 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
    ....
    ....
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
 Error creating bean with name 'userAdminViewController': 
Unsatisfied dependency expressed through field 'userProfileService'; nested exception is 
org.springframework.beans.factory.CannotLoadBeanClassException: 
**Cannot find class [org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer]** 
for bean with name 'org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer#0' defined in class path resource [UserAdminTest-portlet.xml]; 
nested exception is java.lang.ClassNotFoundException: org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)

UserAdminTest-portlet.xml content is UserAdminTest-portlet.xml 内容是

<?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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/util
                           http://www.springframework.org/schema/util/spring-util-3.0.xsd">


    <bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" />

    <bean id="velocityEngineFactoryBean" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
     <property name="resourceLoaderPath" value="/WEB-INF/classes/mailTemplates/"/>
   </bean>

    <bean
        class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="webBindingInitializer">
            <bean
                class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="validator" ref="hibernateValidator" />
            </bean>
        </property>

    </bean>
    <bean id="hibernateValidator"
        class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="validationMessageSource">
            <ref bean="messageSource" />
        </property>
    </bean>

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>content.messages</value>
            </list>
        </property>
    </bean> 
</beans>

The same code is worked without fail with below dependencies相同的代码可以在以下依赖项下正常工作

<spring.version>3.0.5.RELEASE</spring.version>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8</version>
      <scope>test</scope>
    </dependency>

We have changed above dependencies with below ones as the part of upgrade作为升级的一部分,我们已将上述依赖项更改为以下依赖项

<spring.version>4.3.25.RELEASE</spring.version>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>

with above dependencies it throws this exception at the time of executing test cases Cannot find class org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer具有上述依赖项,它在执行测试用例时抛出此异常找不到类 org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

Anyway i have changed spring-xx-xsd schema's to 4.0 but no luck无论如何,我已将 spring-xx-xsd 架构更改为 4.0,但没有运气

Thanks M.deinum感谢M.deinum

I have followed Your suggestion & I resolved this issue by doing few more things我已按照您的建议进行操作,并通过多做几件事解决了此问题

Placed this code inside UserAdminTest-portlet.xml将此代码放在UserAdminTest-portlet.xml 中

    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="ignoreResourceNotFound" value="false"/>
        <property name="order" value="1" />

    </bean>

After that it throwed this之后它抛出了这个

java.lang.NoClassDefFoundError: org/hibernate/validator/spi/resourceloading/ResourceBundleLocator

For this in pom.xml, I have upgraded hibernate validator version to为此,在 pom.xml 中,我已将休眠验证器版本升级为

<hibernate.validator.version>6.1.0.Final</hibernate.validator.version>

Then i got another issue,然后我又遇到了一个问题,

javax.validation.ValidationException: HV000183: 
Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, 
or use ParameterMessageInterpolator instead

I have placed javax-el dependency我已经放置了 javax-el 依赖项

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.el</artifactId>
    <version>3.0.1-b08</version>
</dependency>

Then, Build Success.然后,建立成功。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dispatcher-Servlet.xml找不到名称为Bean的类[org.springframework.web.servlet.mvc.support] - Dispatcher-Servlet.xml Cannot find class [org.springframework.web.servlet.mvc.support] for bean with name Spring-找不到org / springframework / context / event / EventListenerFactory的类文件 - Spring - Cannot find class file for org/springframework/context/event/EventListenerFactory 无法解析 org.springframework.context.support.GenericApplicationContext 类型。 它是从所需的 .class 文件间接引用的 - The type org.springframework.context.support.GenericApplicationContext cannot be resolved. It is indirectly referenced from required .class files org.springframework.boot.context.event.ApplicationFailedEvent无法转换为org.springframework.boot.web.context.WebServerInitializedEvent - org.springframework.boot.context.event.ApplicationFailedEvent cannot be cast to org.springframework.boot.web.context.WebServerInitializedEvent 找不到bean的类[org.springframework.web.servlet.view.InternalResourceViewResolver] - Cannot find class [org.springframework.web.servlet.view.InternalResourceViewResolver] for bean 在Spring Web应用程序中找不到类[org.springframework.scheduling.quartz.SchedulerFactoryBean] - Cannot find class [org.springframework.scheduling.quartz.SchedulerFactoryBean] in Spring web app 无法访问 org.springframework.context.ConfigurableApplicationContext 类文件 - cannot access org.springframework.context.ConfigurableApplicationContext class file 找不到 class org.springframework.web.servlet.mvc.annotation.RequestMappingHandlerMapping - Cannot find class org.springframework.web.servlet.mvc.annotation.RequestMappingHandlerMapping 找不到软件包org.springframework.web.servlet - Cannot find package org.springframework.web.servlet org.springframework.beans.factory.CannotLoadBeanClassException:找不到类[org.springframework.orm.hibernate5.HibernateTrasactionManager] - org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.HibernateTrasactionManager]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM