idea new web project maven jetty

0.转载自http://blog.csdn.net/qwdafedv/article/details/79448332


1.file–>new–>project–>选中maven–>勾选右边的Create from archetype 并选中下拉框中的 org.apache.maven.archetypes:maven-archetype-webapp –>点击 next –>GroupId 和 ArtifactId

GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构。
ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。
一般来说,包的命名习惯是域名的反过来,加个公司或者个人的名称吧,个人习惯。www.demo.com -> com.richard.demo; 
那么都知道,test是项目名称,也是在最后面的,所有项目组的唯一标识符(groupId):com.richard, 项目的唯一标识符(ArtifactId)demo. 
这样你就知道大概对应填些什么东西了。

2.点击next–>你可以override成本地的maven路径,并且在下方添加 name:archetypeCatalog;value:internal–>点击next–>点击左下角的more settings,可以修改module name–>点击next


3.打开pom.xml文件,在build标签中添加 jetty plugin

    <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.4.8.v20171121</version>

                    <configuration>
                        <webApp>
                            <!-- 此处名称为路径访问的名称 -->
                            <contextPath>/demo</contextPath>
                        </webApp>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

4.在web.xml中添加

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

5.在idea右上角 下拉框中选择 Edit Configurations–>点击左上角的加号–>name:随便起,自己辨识就好–>working directory:module所在目录,默认已选择–>command line: jetty:run–>点击OK


6.在idea右上角下拉框中选择上一步配置好的选项,并点击右边相邻的run按钮


7.在浏览器中输入http://localhost:8080/demo,此处的demo为第三步的contextPath的value–>输出 hello world。


猜你喜欢

转载自blog.csdn.net/qwdafedv/article/details/79448332
今日推荐