Не удается найти класс org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer - PullRequest
0 голосов
/ 17 марта 2020

мы обновили нашу версию Project Spring с 3.1.2.RELEASE до 4.3.25.RELEASE .

Я не нашел ошибок, связанных с кодом , Но тестовые случаи Junit дают сбой, выдавая ниже Ошибка

Не удается найти класс [org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

Журнал ошибок

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-портлет. 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>

Тот же код работает в обязательном порядке с приведенными ниже зависимостями

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

Мы изменили вышеупомянутые зависимости с нижеследующими как часть обновления

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

с вышеупомянутыми зависимостями, это выдает это исключение во время выполнения тестовых случаев Не удается найти класс org.springframework.web .context.support.ServletContextPropertyPlaceholderConfigurer

В любом случае я изменил схему spring-xx-xsd на 4.0, но не повезло

1 Ответ

0 голосов
/ 18 марта 2020

Спасибо M.deinum

Я выполнил ваше предложение и решил эту проблему, выполнив несколько других действий

Поместил этот код в UserAdminTest-портлет . 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>

После этого он выбросил

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

Для этого в пом. xml я обновил версию средства проверки гибернации до

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

Затем я получил еще одну проблему,

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

Я поместил зависимость javax-el

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

Затем, Успешная сборка.

...