zoukankan      html  css  js  c++  java
  • java Resource

    ClassPathResource:

      String resource = ""; //相对路径

      Resource resource = new ClassPathResource(resource);

      //获取当前类下,同一个包中的资源

      Resource resource = new ClassPathResource("文件名称",this.getClass());

    FileSystemResource:

      String resource = "";

      //文件系统的真实路径

       Resource resource = new FileSystemResource(resource);

    UrlResource:

        String resource = "httP://...";

          resource = "file://c:/applic...";

         Resource resource = new UrlResource("file://c:/applicationContext.xml");

    ServletContextResource:

      需要在web环境中才可以

       Resource resource = new ServletContextResource(servletContext,"/WEB-INF/classes/applicationContext.xml");

    我们在使用spring容器的时候,由于applicationContext是beanFactory子类,封装了更多方法功能供我们调用,所以在使用applicationContext时,会使用特定格式的字符串表示各种类型

    classPath:loaded from the classpath

    file:loaded as a URL,from the fileSystem

    http:  loaded as a URL

    none   /data/config.xml    Depends on the underlying ApplicationContext

  • 相关阅读:
    docker swarm 集群搭建和臫servoce对服务扩容
    docker 可视化 portainer
    docker Compose
    hadoop2 安装
    y的最大值最小值切割
    滑块图片拼接
    ast 对象还原
    babel/types is判断
    t.isLiteral()
    杂题集合
  • 原文地址:https://www.cnblogs.com/cr1719/p/3841853.html
Copyright © 2011-2022 走看看