Could not open ServletContext resource [/dataSource.properties]

 这个问题刚开始会很常见,经常忘记在写路径的地方加上classpath:

    <!--数据源-->
    <context:property-placeholder location="classpath:pro.properties"/>
    <bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource">
        <property name="driverClassName" value="${mysql.driver}"/>
        <property name="url" value="${mysql.url}"/>
        <property name="username" value="${mysql.username}"/>
        <property name="password" value="${mysql.password}"/>
    </bean>

比如springmvc.xml中如果不写classpath就会报如下的错:

ServletContext resource [/com/tjcu/mapper/] cannot be resolved to URL because it does not exist

    <!--SqlSessionFactory-->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
        <property name="dataSource" ref="dataSource"/>
        <property name="mapperLocations" value="classpath:com/tjcu/mapper/*.xml"/>
        <property name="typeAliasesPackage" value="com.tjcu.entity"/>
    </bean>

web.xml:

  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc.xml</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

后续如果再遇到类似的,再补充......

上一篇:这个error: could not convert ‘cv::Scalar_((double)qBlue()(rgb),


下一篇:could not execute statement长数据做参数报错