为什么当我在Jetty上运行使用Maven创建的项目时,找不到它(404)?

时间:2015-01-25 14:47:09

标签: maven jetty vaadin

我开始阅读Vaadin 7 CookBook,我现在陷入困境:

We are done and we can run our new web application. Go to the root of the project where pom.xml file is located and run the following command.
mvn jetty:start

当我运行该命令时,我立即遇到了一些问题:

Maven: No plugin found for prefix 'jetty' in the current project...

这对我有所帮助:

http://blog.loxal.net/2014/03/maven-no-plugin-found-for-prefix-jetty.html

  

在〜/ .m2 / settings.xml中添加如下内容          org.mortbay.jetty ...解决此问题。

现在码头开始了:

$ mvn jetty:start
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] vaadin-in-maven-arch-parent
[INFO] vaadin-in-maven-arch-widgetset
[INFO] vaadin-in-maven-arch-ui
[INFO] vaadin-in-maven-arch-production
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building vaadin-in-maven-arch-parent 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:8.1.16.v20140903:start (default-cli) > validate @ vaadin-in-maven-arch >>>
[INFO] 
[INFO] <<< jetty-maven-plugin:8.1.16.v20140903:start (default-cli) < validate @ vaadin-in-maven-arch <<<
[INFO] 
[INFO] --- jetty-maven-plugin:8.1.16.v20140903:start (default-cli) @ vaadin-in-maven-arch ---
[INFO] Configuring Jetty for project: vaadin-in-maven-arch-parent
[INFO] webAppSourceDirectory not set. Defaulting to /Users/user/vaadin-in-maven-arch/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /Users/user/vaadin-in-maven-arch/target/classes does not exist
[INFO] Context path = /
[INFO] Tmp directory = /Users/user/vaadin-in-maven-arch/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = null
[INFO] Webapp directory = /Users/user/vaadin-in-maven-arch/src/main/webapp
2015-01-25 17:29:25.569:INFO:oejs.Server:jetty-8.1.16.v20140903
2015-01-25 17:29:25.758:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2015-01-25 17:29:26.526:WARN:oejsh.RequestLogHandler:!RequestLog
2015-01-25 17:29:26.555:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

他们在书中向前推进说:

The application will be running on http://localhost:8080.

但是当我在浏览器中打开http://localhost:8080时,我得到了404 Not Found:

enter image description here

我还尝试了http://localhost:8080/webapphttp://localhost:8080/vaadin-in-maven-arch/targethttp://localhost:8080/main/webapp,但他们都没有工作。

问题出在哪里?我该如何解决?

感谢您的关注!

编辑:以下是项目对象模型的内容:

<?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>

    <groupId>app</groupId>
    <artifactId>vaadin-in-maven-arch</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>vaadin-in-maven-arch-parent</name>

    <properties>
        <vaadin.version>7.4.0.beta2</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
        <jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
        <project.source.version>1.7</project.source.version>
        <project.target.version>1.7</project.target.version>
        <project.encoding>UTF-8</project.encoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <encoding>${project.encoding}</encoding>
                    <source>${project.source.version}</source>
                    <target>${project.target.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>${project.encoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-server</artifactId>
                <version>${vaadin.version}</version>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-push</artifactId>
                <version>${vaadin.version}</version>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-client</artifactId>
                <version>${vaadin.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-client-compiler</artifactId>
                <version>${vaadin.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-themes</artifactId>
                <version>${vaadin.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
        <repository>
            <id>vaadin-snapshots</id>
            <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
            </snapshots>
        </repository>

    </repositories>
  <modules>
    <module>vaadin-in-maven-arch-widgetset</module>
    <module>vaadin-in-maven-arch-ui</module>
    <module>vaadin-in-maven-arch-production</module>
  </modules>
</project>

1 个答案:

答案 0 :(得分:1)

您最有可能尝试在错误的文件夹中运行jetty。请改为使用vaadin-in-maven-arch-ui文件夹。

而不是jetty:start尝试使用jetty:run