我尝试使用以下类为Nexus2插件创建REST端点:
@Path(NexusPlugin.URI)
@Named
@Singleton
public class NexusPlugin extends ComponentSupport implements Resource {
public static final String URI ="/nexusplugin";
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response get(){
return Response.ok("Config Updated").build();
}
}根据我的理解,实现Resource接口应该足够了,Nexus/siesta应该实例化该类并创建Resource。我不使用任何web.xml,目前也不单独实例化该类。
该代码基于Nexus2 测井插件的代码,该代码还提供了REST端点,我可能遗漏了一些东西。
午睡总是以错误的形式返回:
{
"id": "ae015d47-5968-4cb6-88c3-d5615c677c0c",
"message": "No resource available at 'nexusplugin'"
}Nexus2日志显示以下错误:
admin org.sonatype.sisu.siesta.server.internal.SiestaServlet - Processing: GET /nexus/service/siesta/nexusplugin (http://localhost:8081/nexus/service/siesta/nexusplugin)
2018-01-30 08:40:47,816+0100 DEBUG [esh-1-thread-5] admin org.sonatype.nexus.feeds.record.NexusAuthenticationEventInspector - Successfully authenticated user [admin] from IP address 127.0.0.1
2018-01-30 08:40:47,816+0100 DEBUG [qtp491414393-52] admin org.sonatype.sisu.siesta.server.internal.mappers.WebApplicationExceptionMapper - (ID e92c848c-d603-4541-bb0c-ddd60fddb5e4) Mapping exception: com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8081/nexus/service/siesta/nexusplugin
2018-01-30 08:40:47,820+0100 WARN [qtp491414393-52] admin org.sonatype.sisu.siesta.server.internal.mappers.WebApplicationExceptionMapper - (ID e92c848c-d603-4541-bb0c-ddd60fddb5e4) Response: [404] ErrorXO{id='e92c848c-d603-4541-bb0c-ddd60fddb5e4', message='No resource available at 'nexusplugin''} mapped from com.sun.jersey.api.NotFoundException/null for uri: http://localhost:8081/nexus/service/siesta/nexusplugin
com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8081/nexus/service/siesta/nexusplugin但是,这并不是很有帮助,因为错误是在任意的url上引发的。
发布于 2018-03-02 08:49:28
如果问题最终得到解决。pom.xml中午睡插件的依赖性需要以下附加行:
<type>${nexus-plugin.type}</type>所以看起来是这样的:
<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-siesta-plugin</artifactId>
<version>2.13.0-01</version>
<type>${nexus-plugin.type}</type>
<scope>provided</scope>
</dependency>https://stackoverflow.com/questions/48516400
复制相似问题