1. 程式人生 > >如果出現context閃紅的情況,解決方案

如果出現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的相關檔案,直接使用自然會報錯