0

谁能提供 Jersey 和 Embedded Tomcat 的简单配置:1)pom.xml 2)主要方法

我试图在谷歌搜索中找到它,但他们建议使用 grizzly、glassfish 等。

非常感谢。

4

1 回答 1

0

我会去webapp-runner运行网络应用程序。它将来自 /target 的 maven 生成的战争部署到内置的 tomcat 容器中。这就是在 Heroku 上部署 java 应用程序的方式。
pom插件配置:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.github.jsimone</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>7.0.34.1</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

依赖:

    <dependency>
        <groupId>com.github.jsimone</groupId>
        <artifactId>webapp-runner</artifactId>
        <version>7.0.34.1</version>
        <scope>provided</scope>
    </dependency>

之后运行应用程序mvn clean package

java -jar target\dependency\webapp-runner.jar target\myapp.war
于 2013-08-08T00:47:03.693 回答