How to include a config file in the “META-INF/services” folder of a JAR using Maven

前端 未结 3 1328
-上瘾入骨i
-上瘾入骨i 2020-12-12 23:36

I\'m working on a Java project in Eclipse, which is built using Maven. I\'m using some recycled code from an older project, and one of these classes looks for a file in the

3条回答
  •  萌比男神i
    2020-12-12 23:51

    Create a new source folder with the location src/main/resources, then create your META-INF/services folder in there and drop in your FQCN file. This should copy them into the jar file automatically. So you'll have:

    Project
    | src
    | | main
    |   | java
    |     | [your source code]
    |   | resources
    |     | META-INF
    |       | services
    |         | [your service files]
    

    It's worth noting that this applies to Gradle projects with the default source sets as well.

提交回复
热议问题