zoukankan      html  css  js  c++  java
  • ClassPathXmlApplicationContext和FileSystemXmlApplicationContext路径问题

    1.Spring中ClassPathXmlApplicationContext问题

    ClassPathXmlApplicationContext是从ClassPath类加载路径下加载对应的xml文件的。

    (1)一般使用classpath路径,前缀可加可不加,

    例如:new ClassPathXmlApplicationContext("classpath:conf/core/train-servlet.xml")

    (2)也可以使用绝对路径,加上file:表示绝对路径,一般不建议使用绝对路径

    2. FileSystemXmlApplicationContext:

    (1)用文件系统的路径,默认指定项目的根路径, src

    例如:new FileSystemXmlApplicationContext("src/conf/core/train-servlet.xml")

    (2)也可以使用classpath路径,这样就能读到classpath下面的相对路径,

    例如:new FileSystemXmlApplicationContext("classpath:conf/core/train-servlet.xml")

    (3)不需要加file: 前缀表示绝对路径,不提倡使用

    1.没有盘符的是项目工作路径,即项目的根目录; src

    2.有盘符表示的是文件绝对路径. D: est 报错问题:

    NoClassDefFoundError原因是相应的类没有找到,查看 spring.xml文件中,相应的bean时候有配置错误。

  • 相关阅读:
    Python实现网络多人聊天室
    C实现string字符串
    C getchar()
    C++ 数组遍历的两种方式
    Java 发红包
    Java递归实现阶乘
    Go defer语句
    bash shell——sum
    C——letterCounter
    数据结构——链队列(linked queue)
  • 原文地址:https://www.cnblogs.com/alisonGavin/p/6870056.html
Copyright © 2011-2022 走看看