Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.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 在glassfish中更改企业应用程序(ear)的上下文路径_Java_Glassfish - Fatal编程技术网

Java 在glassfish中更改企业应用程序(ear)的上下文路径

Java 在glassfish中更改企业应用程序(ear)的上下文路径,java,glassfish,Java,Glassfish,可以在glassfish中更改web应用程序war的上下文路径,但是有没有任何解决方案可以更改企业应用程序ear的上下文路径 我尝试将其从glassfish-web.xml更改为: <!-- Default context --> <context-root>/module1-web</context-root> <!-- New context --> <context-root>/erp/module1-web</conte

可以在glassfish中更改web应用程序war的上下文路径,但是有没有任何解决方案可以更改企业应用程序ear的上下文路径

我尝试将其从glassfish-web.xml更改为:

<!-- Default context -->
<context-root>/module1-web</context-root>

<!-- New context -->
<context-root>/erp/module1-web</context-root>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <version>6</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <applicationName>your_application</applicationName>
                <modules>
                    <webModule>
                        <groupId>com.yourcompany</groupId>
                        <artifactId>your-web-module</artifactId>
                        <contextRoot>/your-web-module</contextRoot>
                        <excluded>false</excluded>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
但它不起作用。我试图从服务器上更改它,但没有办法更改它

Web应用程序上下文路径

那个问题有什么解决办法吗


谢谢。

是的,您的问题有解决方案

您需要在EAR的META-INF文件夹中放置一个名为application.xml的文件

以下是文件的外观示例:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <application-name>your_application</application-name>
  <display-name>your_application</display-name>
  <module>
    <web>
      <web-uri>your-war-file.war</web-uri>
      <context-root>/your_desired_context</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>another-war-file.war</web-uri>
      <context-root>/another/context/for/the/second/war/file</context-root>
    </web>
  </module>
  <module>
    <ejb>ejb-module-example.jar</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>
如您所见,您还可以使用不同的上下文路径声明多个web模块

您可以使用生成文件,有关更多信息,请参阅

下面是一个如何使用插件的示例:

要使其工作,您必须将web模块WAR分离到一个额外的maven项目中。然后您可以在插件配置中引用它,如下所示:

<!-- Default context -->
<context-root>/module1-web</context-root>

<!-- New context -->
<context-root>/erp/module1-web</context-root>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <version>6</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <applicationName>your_application</applicationName>
                <modules>
                    <webModule>
                        <groupId>com.yourcompany</groupId>
                        <artifactId>your-web-module</artifactId>
                        <contextRoot>/your-web-module</contextRoot>
                        <excluded>false</excluded>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>

是的,你的问题有解决办法

您需要在EAR的META-INF文件夹中放置一个名为application.xml的文件

以下是文件的外观示例:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <application-name>your_application</application-name>
  <display-name>your_application</display-name>
  <module>
    <web>
      <web-uri>your-war-file.war</web-uri>
      <context-root>/your_desired_context</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>another-war-file.war</web-uri>
      <context-root>/another/context/for/the/second/war/file</context-root>
    </web>
  </module>
  <module>
    <ejb>ejb-module-example.jar</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>
如您所见,您还可以使用不同的上下文路径声明多个web模块

您可以使用生成文件,有关更多信息,请参阅

下面是一个如何使用插件的示例:

要使其工作,您必须将web模块WAR分离到一个额外的maven项目中。然后您可以在插件配置中引用它,如下所示:

<!-- Default context -->
<context-root>/module1-web</context-root>

<!-- New context -->
<context-root>/erp/module1-web</context-root>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <version>6</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <applicationName>your_application</applicationName>
                <modules>
                    <webModule>
                        <groupId>com.yourcompany</groupId>
                        <artifactId>your-web-module</artifactId>
                        <contextRoot>/your-web-module</contextRoot>
                        <excluded>false</excluded>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>

谢谢@unwichtich这应该有助于我你可以用一个例子来解释maven的更多方式吗?我已经添加了一个例子。谢谢@unwichtich Alothank你@unwichtich这应该有助于我你可以用一个例子来解释maven的更多方式吗?我已经添加了一个例子。谢谢@unwichtich alot