Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在没有数据源的wildfly中发动战争_Java_Jakarta Ee_Jboss_Wildfly - Fatal编程技术网

Java 在没有数据源的wildfly中发动战争

Java 在没有数据源的wildfly中发动战争,java,jakarta-ee,jboss,wildfly,Java,Jakarta Ee,Jboss,Wildfly,我得到了一个荒谬的错误: jboss.naming.context.java.module.helloworld.helloworld.DefaultDataSource缺少[jboss.naming.context.java.jboss.datasources.examples] 因为我的战争不需要坚持,所以我没有得到。我真的需要一个数据源来发动战争吗?这不是一个错误。 JavaEE7强制使用DefaultDataSource。 仅仅因为您没有对它的资源引用并不意味着您不查找它,所以Wildf

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

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

因为我的战争不需要坚持,所以我没有得到。我真的需要一个数据源来发动战争吗?

这不是一个错误。 JavaEE7强制使用DefaultDataSource。 仅仅因为您没有对它的资源引用并不意味着您不查找它,所以Wildfly必须提供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;

您使用的是stock standalone.xml配置文件,还是试图在文本编辑器中对其进行更改?我刚刚使用管理控制台将其取出。然后我又加了回去,现在一切正常了。我觉得这应该是一个bug,在我看来,您复制了一些示例代码,在java类或部署描述符中的某个地方还保留着一个数据源引用。您是如何部署应用程序的?这是有道理的,但为什么JavaEE的创建者会强制要求这样做呢?我记得Arun Gupta说过,它应该可以简化初学者的学习过程。至少您现在能够启动一个使用JPA的应用程序,而不必担心之前安装和配置数据库。