首页 文章

在没有Datasource的wildfly中启动.war

提问于
浏览
0

我得到了这个荒谬的错误:

缺少jboss.naming.context.java.module.helloworld.helloworld.DefaultDataSource [jboss.naming.context.java.jboss.datasources.ExampleDS]

自从我的战争不使用持久性以来,我没有得到 . 我真的需要一个数据源来发动战争吗?

1 回答

  • 2

    那不是错误 . JavaEE 7强制要求DefaultDataSource . 仅仅因为你没有资源引用它并不意味着你不查找它,所以Wildfly必须提供java:comp / DefaultDataSource,它映射到ExampleDS:

    EE.5.19 Default Data Source
    The Java EE Platform requires that a Java EE Product Provider provide a database
    in the operational environment (see Section EE.2.6, “Database”). The Java EE
    Product Provider must also provide a preconfigured, default data source for use by
    the application in accessing this database.
    
    The Java EE Product Provider must make the default data source accessible to
    the application under the JNDI name java:comp/DefaultDataSource.
    
    The Application Component Provider or Deployer may explicitly bind a
    DataSource resource reference to the default data source using the lookup element
    of the Resource annotation or the lookup-name element of the resource-ref
    deployment descriptor element. For example,
    
    @Resource(lookup="java:comp/DefaultDataSource")
    DataSource myDS;
    
    In the absence of such a binding, the mapping of the reference will default to
    the product's default data source.
    
    For example, the following will map to a preconfigured data source for the
    product's default database:
    
    @Resource
    DataSource myDS;
    

相关问题