繁体   English   中英

在没有数据源的Wildfly中启动.war

[英]Launch .war in wildfly with no Datasource

我收到这个荒谬的错误:

jboss.naming.context.java.module.helloworld.helloworld.DefaultDataSource丢失[jboss.naming.context.java.jboss.datasources.ExampleDS]

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

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

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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM