maven路径配置

先写经验 :这类约定优于配置的思想,是为了方便大家更好得使用软件,大家不要作死非要自己去改路径。



问题的发现,是因为作死想自己去指定log4j的路径,绝对路径是没问题的,但是相对路径会报错。PropertyConfigurator.configure();最终也没法解决。在IDE或jar包中可以通过getClassLoader().getResource("log4j.properties");来获得存在于CLASSPATH中资源文件。


为了解决相对路径的问题,查阅了chasspath文件,并怀疑是excluding搞的鬼,但结果发现不是。

<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>


excluding="**" 的解释,中文基本找不到资料,最终找到比较合理的解释,是指使输出文件中,不要resource层级,而是直接文件显示。但是搞了2个小时,无法复现删除和不删除的区别。自己就这么理解,没去深究,因为本来就约定由于配置,你非要自己这么搞,钻牛角尖反而违反了本来使用工具的意义。

<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> 

> Because of the excluding="**"  statement the package explorer in Eclipse does 
> not show the resources in the "flat package presentation" anymore. 
> Rather the resources are shown in the "hierarchical package presentation". 
> This is very annoying if you have a deep package structure with just a view resources. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值