gpt4 book ai didi

java - Glassfish 4 上的 Weld 001508 异常 : how to ignore interface(s)?

转载 作者:太空宇宙 更新时间:2023-11-04 13:07:08 27 4
gpt4 key购买 nike

问题:尝试将 WAR 部署到 Glassfish 4.1.1 时,我不断收到下面的 WELD 异常。该应用程序在 Wildfly 9.0 上正确部署。

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.jboss.weld.exceptions.DefinitionException: WELD-001508: Cannot create an InjectionTarget from [EnhancedAnnotatedTypeImpl] public abstract interface @Path class com.example.package.MyService as it is an interface

这里,MyService确实是一个接口(interface),在单独的库中定义。我的应用程序引入该库,以便它可以针对 MyService 接口(interface)创建代理并发出请求。 MyService 看起来像:

@Path("api")
public interface MyService {

@GET
public void someMethod();
}

我尝试通过将以下内容添加到 beans.xml 文件中来从 WELD 中排除 MyService,但无济于事:(

<scan>
<exclude name="com.example.package.*"></exclude>
</scan>
  • 为什么 WELD 试图包含该库的界面?
  • 我如何告诉它忽略它?

最佳答案

您还可以尝试创建package-info.java文件并使用@Vetoed:

@Vetoed
package com.example.package;

import javax.enterprise.inject.Vetoed;

关于java - Glassfish 4 上的 Weld 001508 异常 : how to ignore interface(s)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34323488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com