java – 对jetty-env.xml感到困惑

我有一个使用JNDI来定位数据源和事务管理器的webapp.我从Jetty文档中看到如何通过jetty-env.xml文件执行此操作.但是它提到应该将此文件放入WEB-INF目录中.

为什么他们建议在我的WAR内部的配置文件中配置JNDI资源?这没有任何意义……我一直认为JNDI是一种外部化配置的方式.还有另一个地方我可以把这个文件放在Jetty服务器上吗?

一个后续问题:在我的Maven WAR模块中怎么样…我应该如何处理这个文件以便我可以使用Maven jetty插件进行开发,但是文件最终没有在WAR中?

最佳答案:

Is there another place I can put this file on a Jetty server machine?

官方JNDI页面如下:

There are 3 places in which you can
define naming entries:

  1. jetty.xml
  2. WEB-INF/jetty-env.xml
  3. context xml file

Naming entries defined in a
jetty.xml file will generally be
scoped at either the jvm level or the
Server level. Naming entries in a
jetty-env.xml file will generally be
scoped to the webapp in which the file
resides, although you are able to
enter jvm or Server scopes if you
wish, that is not really recommended.
In most cases you will define all
naming entries that you want visible
to a particular Server instance, or to
the jvm as a whole in a jetty.xml
file. Entries in a context xml file
will generally be scoped at the level
of the webapp to which it applies,
although once again, you can supply a
less strict scoping level of Server or
jvm if you want.

使用jetty.xml配置webapp“之外”的内容.

A follow up question: How about within my Maven WAR module…how should I deal with this file so that I can use the Maven jetty plugin for development, but not have the file end up in the WAR?

使用Maven Jetty Plugin的jettyConfig参数:

jettyConfig Optional. The location of a jetty.xml file that will be applied in addition to any plugin configuration parameters. You might use it if you have other webapps, handlers etc to be deployed, or you have other jetty objects that cannot be configured from the plugin.

上一篇:java-我可以在同一实例中使用WebSocketHandler运行WebAppContext吗?


下一篇:java – Haproxy Bad Gateway 502