Maven项目URL

时间:2015-06-19 15:53:49

标签: maven url netbeans glassfish

我在Glassfish上运行的NeatBeans IDE中创建了一个EAR项目,并且项目的默认URL出现了问题,而不是加载:

http://localhost:8080/Opine-war

正在加载

http://localhost:8080/Opine-war-1.0-SNAPSHOT

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-application PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Java EE Application 6.0//EN" "http://glassfish.org/dtds/glassfish-application_6_0-1.dtd">
<glassfish-application>
</glassfish-application>

这是我的pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>Opine</artifactId>
    <groupId>br.edu.infnet</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

    <groupId>br.edu.infnet</groupId>
    <artifactId>Opine-ear</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>ear</packaging>

    <name>Opine-ear</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <version>6</version>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>br.edu.infnet</groupId>
            <artifactId>Opine-ejb</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>br.edu.infnet</groupId>
            <artifactId>Opine-war</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>
</project>

1 个答案:

答案 0 :(得分:0)

我认为有两种选择。一种是更改pom.xml中的finalName:

<build>
    <finalName>${project.artifactId}-${project.version}</finalName>
上面的

显示默认值。

另一个选项是更改当前从ear文件名派生的应用程序的上下文名称。但是部署的耳朵不需要匹配上下文名称(你想成为&#34; Opine-war&#34;?

您可以在耳内插件中自定义此内容(如果您使用<packaging>ear</packaging>,则会启用此插件:https://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-context-root.html