我有三个类的简单maven项目.在我,META-INF我有空beans.xml.每次我跑我的时候Main.java我都会得到一个NullPointerException.
Exception in thread "main" java.lang.NullPointerException
at hom.World.helloWorld(World.java:12)
at hom.Main.main(Main.java:6)
Run Code Online (Sandbox Code Playgroud)
我想要完成的是否超出CDI的范围?
Hello.java
package hom;
import javax.enterprise.inject.Default;
@Default
public class Hello {
public String hello() {
return "Hello ";
}
}
Run Code Online (Sandbox Code Playgroud)
World.java
package hom;
import javax.enterprise.inject.Default;
import javax.inject.Inject;
@Default
public class World {
@Inject
Hello hello;
public String helloWorld() {
return hello.hello() + "World!";
}
}
Run Code Online (Sandbox Code Playgroud)
Main.java
package hom;
public class Main {
public static void main(String[] args) {
World helloWorld = new …Run Code Online (Sandbox Code Playgroud) 我正在调试我的 x64 c++ 程序以了解它在 x64dbg 中的外观。我在右侧窗口中看到一些 r8-r15 的寄存器,但我没有看到r8d. 还有其他人也有类似的情况r15d。那么它是什么?
使用Primefaces 5.0,JSF 2.2.7,部署在EAP 6.1上.
我在下面有这个Managed Bean.
import hh.bean.Service;
import hh.dao.ServiceDao;
import hh.dao.impl.ServiceDaoImpl;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class View1 implements Serializable {
private static final long serialVersionUID = 1L;
private ServiceDao serviceDao = new ServiceDaoImpl();
@PostConstruct
public void init() {
System.out.println(View1.class.getName() + ": init() " + this);
}
public List<Service> getServices(){
return serviceDao.getAllServices();
}
}
Run Code Online (Sandbox Code Playgroud)
我从下面的xhtml中调用它.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Home Web</title>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta …Run Code Online (Sandbox Code Playgroud)