【问题标题】:Run with Netbeans (and Maven) the right context root使用 Netbeans(和 Maven)运行正确的上下文根
【发布时间】:2012-10-25 07:29:03
【问题描述】:

当我从 Netbeans 7.2(我也使用 Glassfish 3.1.2 服务器)运行项目时遇到了一个小问题......

事实上,我正在将现有项目从 Ant 迁移到 Maven,我的 pom.xml 已经完成,并且我已经使用了上下文根的自定义,如下所述:http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-context-root.html 但是当我从 netbeans 运行项目时,它以我的 .ear 名称部署: localhost:8080/MyApplicationEAR-0.1-SNAPSHOT 代替 localhost:8080/MyApplicationName(在<contextRoot>/MyApplicationName</contextRoot>中引用)

如果我在浏览器中编写正确的 URL,它可以正常工作,但不是很愉快。

Netbeans 有问题还是我忘记了什么?

编辑:application.xml 是由 Maven 自动生成的,并且 context-root 格式正确,但似乎 Netbeans 对此无关紧要......

【问题讨论】:

    标签: maven netbeans glassfish contextpath application.xml


    【解决方案1】:

    如果您使用 Maven 并部署到 JBoss,试试这个。

    您应该编辑 pom.xml 文件并将以下行添加到 <build> 部分。

    <finalName>${artifactId}</finalName>
    

    【讨论】:

      【解决方案2】:

      我刚刚使用 Netbeans 7.3 beta 进行了尝试,它可以工作。

      我假设你在你的模块标签中加入了 artifact 和 groupId 标签。如果不是这可能是你的问题。 这里以我的插件配置为例:

               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-ear-plugin</artifactId>
                  <version>2.8</version>
                  <configuration>
                      <version>6</version>
                      <defaultLibBundleDir>lib</defaultLibBundleDir>
                      <generateApplicationXml>true</generateApplicationXml>
                      <applicationName>Gen</applicationName>
                      <modules>
                          <ejbModule>
                              <artifactId>Testing-ejb</artifactId>
                              <groupId>de.roeperweise.testing</groupId>
                              <bundleFileName>ejb.jar</bundleFileName>
                          </ejbModule>
                          <webModule>
                              <artifactId>Testing-web</artifactId>
                              <groupId>de.roeperweise.testing</groupId>
                              <bundleFileName>web.war</bundleFileName>
                              <contextRoot>/custom</contextRoot>                         
                          </webModule>
                      </modules>
                  </configuration>
              </plugin>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        • 1970-01-01
        • 1970-01-01
        • 2012-03-30
        • 2010-11-04
        • 2019-05-13
        相关资源
        最近更新 更多