首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到EntityManager Apache Deltaspike

找不到EntityManager Apache Deltaspike
EN

Stack Overflow用户
提问于 2017-06-16 16:46:08
回答 0查看 994关注 0票数 0

我尝试打印存储库中包含的查询的行数。以下是存储库:

代码语言:javascript
复制
@Repository
public interface TagRepository extends EntityRepository<Tag, Long> {

    /**
    * @param //
    * @return all Tag matched
    */
   @Query("SELECT * FROM Tag") //TESTED
   List<Tag> findByDefault(); 
}

这是我的控制器:

代码语言:javascript
复制
@Named
@ViewScoped
public class ControllerTest implements Serializable {

/**
 * 
 */
   private static final long serialVersionUID = 1L;
   @Inject
   private TagRepository tagRepository;

   public ControllerTest()
   {
       super();
   }

   public Integer compte()
   {
       return tagRepository.findByDefault().size();
   }

   public String essai()
   {
       String message = "Hello World !";
       return message;
   }
}

这是我的*.xhtml文件:

代码语言:javascript
复制
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ds="http://deltaspike.apache.org/jsf"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich" template="/layout/template.xhtml" 
xmlns:a4j="http://richfaces.org/a4j">

<ui:define name="body">
    <rich:collapsiblePanel switchType="client" opened="false" label="Updates version 2.2.7">
            <h:outputText 
                value="#{controllerTest.compte()}">         
            </h:outputText>
            <h:outputText 
                value="#{controllerTest.essai()}">          
            </h:outputText>
            <h:outputText 
                value="Hello world !">          
            </h:outputText>
    </rich:collapsiblePanel>
</ui:define>

布局使用方法essai()运行得很好,但是当我使用方法compte()时:

代码语言:javascript
复制
javax.servlet.ServletException: Exception calling Repository: [Repository=class repositories.TagRepository$$DSPartialBeanProxy,method=findByDefault],exception=class java.lang.IllegalStateException,message=Could not find EntityManager with default qualifier.

我认为Apache Deltaspike能够通过注释来管理bean。

问题是:这个问题从何而来?这是我的存储库吗?我错过了什么吗?我仍然在谷歌上搜索了这个,但没有关于Apache Deltaspike的。

我使用Wildfly 10.0.0,Hibernate 5.4.1,Eclipse Neon,RichFaces 4.X,JSF2.x,Apache Deltaspike 1.7.2。

提前感谢您的回答。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44584768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档