How can I write maven build to add resources to classpath?

后端 未结 3 1116
鱼传尺愫
鱼传尺愫 2020-12-04 21:56

I am building a jar using maven with simple maven install. If I add a file to src/main/resources it can be found on the classpath but it has a config folder whe

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 22:35

    If you place anything in src/main/resources directory, then by default it will end up in your final *.jar. If you are referencing it from some other project and it cannot be found on a classpath, then you did one of those two mistakes:

    1. *.jar is not correctly loaded (maybe typo in the path?)
    2. you are not addressing the resource correctly, for instance: /src/main/resources/conf/settings.properties is seen on classpath as classpath:conf/settings.properties

提交回复
热议问题