20

spring+mybatis+druid+mysql为啥会报:spring xml model Validation

小白小连一下,求各路大神指教:用的idea开发spring+mybatis+druid+mysql
spring+mybatis+druid为啥为啥会报:spring xml model Validation ,
其中加粗字体报spring xml model Validation
而换c3p0不会有spring xml model Validation
我的具体配置如下:
applicationcontext.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<!--开启注解 -->
<context:annotation-config />
<!--扫包 -->
<context:component-scan base-package="com.cgwllx" />

<!-- 读取jdbc配置 -->
<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <!-- jdbc.properties引入-->
            <value>classpath:jdbc.properties</value>
        </list>
    </property>
</bean>

<!--数据库连接池  druid-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <!--读取值 ${key}-->
    <property name="**driverClass**" value="${driverClass}" /> 
    <property name="**jdbcUrl**" value="${jdbcUrl}"></property>
    <property name="**user**" value="${user}" />
    <property name="password" value="${password}" />
</bean>

<!--Mybatis操作数据库 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!--连数据库 -->
    <property name="dataSource" ref="dataSource" />
    <!--xml位置 -->
    <property name="mapperLocations" value="classpath:com/cgwllx/lxfood/dao/***.xml**" />
    <!--PO别名 -->
    <property name="typeAliasesPackage" value="com.cgwllx.lxfood.dao" />

</bean>

<!-- 扫包 扫xml -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.cgwllx.lxfood.dao" />
</bean>



项目结构:
图片说明

jdbc.properties为:
driverClass=mysql.jdbc.Driver

jdbcUrl=mysql://localhost:3306/energizecloud?useUnicode=true&characterEncoding=utf8

user=root

password=1234

pom也引入了该有的依赖:

<!-- spring版本号 -->
4.3.5.RELEASE

        <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.15</version>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>1.0.28</version>
    </dependency>
            <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>


    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
    </dependency> 

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>

            <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.3.0</version>
    </dependency>

    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-spring</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
查看全部
weixin_43944282
weixin_43944282
2019/04/15 12:00
  • spring
  • java
  • maven
  • intellij-idea
  • 点赞
  • 收藏
  • 回答
    私信

3个回复