String path = System.getProperty("user.dir") + "\\src\\main\\resources\\mybatis-config.xml";

运行调试:

导入配置文件

即此不能用于java web,只能用作本地执行文件。

那java web如何导入配置文件?

通过执行发现,src/main/resources下面的xml与properties文件,在编译后会在XXX\target\boms-v2.1.1\WEB-INF\classes,问题演变为如何导入web-inf/class下的配置文件

String path = Thread.currentThread().getContextClassLoader()
        .getResource("pwdmybatis-config.xml").getPath();

转载于:https://my.oschina.net/u/560971/blog/1555023

相关文章:

  • 2021-12-15
  • 2021-05-10
  • 2021-12-18
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-21
猜你喜欢
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2021-05-10
  • 2021-05-21
  • 2021-08-12
  • 2022-12-23
相关资源
相似解决方案