Mojarra 2.3.0-m06,@PersistenceContext 字段为空
Mojarra 2.3.0-m06, @PersistenceContext field is null
我有这样的转换器:
@FacesConverter(managed = true, value = "myConverter")
public class MyConverter implements Converter {
@PersistenceContext(unitName = MyService.PERSISTENCE_NAME)
private EntityManager entityManager;
...
}
问题是 entityManager 为空。 faces-config JSF版本为2.3,使用Mojarra 2.3.0-m06。在Application#createConverter() implementation it jumps into the first if's body, but doesn't create the converter. entityManager is not null when the converter is a bean.
我需要在 WEB-INF 目录中添加一个 beans.xml 文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
我有这样的转换器:
@FacesConverter(managed = true, value = "myConverter")
public class MyConverter implements Converter {
@PersistenceContext(unitName = MyService.PERSISTENCE_NAME)
private EntityManager entityManager;
...
}
问题是 entityManager 为空。 faces-config JSF版本为2.3,使用Mojarra 2.3.0-m06。在Application#createConverter() implementation it jumps into the first if's body, but doesn't create the converter. entityManager is not null when the converter is a bean.
我需要在 WEB-INF 目录中添加一个 beans.xml 文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>