如果出现context闪红的情况,解决方案

如果出现context闪红的情况,

<context:component-scan base-package="delivery" />
<context:property-placeholder location="file:#{systemProperties['webapp.sample']}/WEB-INF/conf/redis.properties" />

<bean id="redisUtil" class="cn.com.taiji.sample.utils.RedisUtil">
    <property name="addr"><value>${redis.addr}</value></property>
    <property name="port"><value>${redis.port}</value></property>
    <property name="auth"><value>${redis.auth}</value></property>
    <property name="maxIdle"><value>${redis.maxIdle}</value></property>
    <property name="maxActive"><value>${redis.maxActive}</value></property>
    <property name="maxWait"><value>${redis.maxWait}</value></property>
    <property name="timeOut"><value>${redis.timeOut}</value></property>
    <property name="testOnBorrow"><value>${redis.testOnBorrow}</value></property>
</bean>

可以在代码的上方加上以下代码:

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

因为没有引入xml的相关文件,直接使用自然会报错

猜你喜欢

转载自blog.csdn.net/weixin_42193081/article/details/83037299