creating META-INF/services folder in Eclipse

后端 未结 2 1699
野趣味
野趣味 2021-02-08 09:03

I am trying to create an extensible app in Java and chose to use SPI. According to this tutorial I am following, I am supposed to create a specific file in META-INF/servic

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 09:08

    Assuming you are building your jar file with Apache's Ant, you need to add a metainf fileset, or better yet, use a services directive like so

    
      
      
    
    

    If you don't use apache's Ant, then you need to add a file to your jar

    jar -uf jarfile.jar META-INF/services/name.of.general.service
    

    which contains the name of the service's implementation

    com.mycorp.services.Fooservice
    

    If you are generating the JAR file using Eclipse's "Runnable Jar file export" under the project, select "save as ANT script" and then modify the ant script to pack in the services as described above.

提交回复
热议问题