我想使用业务层的CDI服务编写一个基于Java SE的小工具。我必须使用maven将所有内容打包成一个与jar-with-.dependencies'。 从小做起我想看一个简单的例子运行。所以我举了一个简单的例子:
public static void main(final String[] args) throws Exception {
Weld weld = new Weld();
System.out.println("Weld constructed");
WeldContainer initialize = weld.initialize(); // exception thrown
System.out.println("Weld init");
TestInject importConfigurationCommand = initialize.instance().select(TestInject.class).get();
importConfigurationCommand.sayHello();
weld.shutdown();
}
Test inject类看起来像这样:
public class TestInject {
public void sayHello() {
System.out.println("Hallo");
}
}
启动时出现以下异常:
Exception in thread "main" java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validate ConstructorArguments(Unknown Source)
这种例外的原因是什么?它指的是哪种参数化类型?