zoukankan      html  css  js  c++  java
  • Eclipe 新建maven web 项目

    eclipse 新建maven web项目:

    1.创建web项目
    空白处---右击--->New---->Other--->MavenProject--->filter webapp--->maven-archetype-webapp

    问题1:
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    解决方案:
    dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <!--tomcat 容器有 api 防止运行时 冲突 provided :编译、测试 classpath 有效 运行无效-->
     <scope>provided</scope>
    </dependency>
    问题2:
    没有出现src/main/java
    src/test/java?
    解决方案:
    1.JRE修改为本地安装 的 jdk
    选中项目中
    JRE System Libary 右击---->Build path--->config build path--->edit 替换为本地安装的jdk 环境
    问题3:
    an error xxxx?
    选中项目----右击--->maven--->update project

    2.maven 项目转换为web项目:

    选中项目----右击--->properties--->Project Facets--->勾选Dynamic web module 并且指定对应的jdk 版本
    3. 检查目录是否生效:
    src-->main -->webapp -->WEB-INF

    4.web项目部署的配置:
    选中项目----右击--->properties--->Depolyment Assembly--->remove test folder
    NOTE:
    maven 项目如果无法正常运行,检查是否maven Dependencies 这个目录

    5.检查文件的classes 文件的输出目录:
    选中项目----右击--->properties--->build path--->Source---> 检查 src/main/java、src/test/java、src/main/resources 是否正确配置
    6.运行web项目
    web 项目运行服务器上面:
    jetty:
    轻量级的web 服务器
    1. jetty:run
    <build>
    <finalName>maven-web</finalName>
    <plugins>
    <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.6.v20151106</version>
    </plugin>
    </plugins>
    </build>

    2.package:

    <build>
    <finalName>maven-web</finalName>
    <plugins>
    <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.6.v20151106</version>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>run</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

    tomcat:

    package
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>run</goal>
    </goals>
    </execution>
    </executions>
    </plugin>


    解决问题总结:
    第一步通过problems view 确定是哪里的问题?

    1. 首先检查是否是指定的本地安装jdk

    2. 具体错误具体对待

    3. mvn clean(排除不想关的 错误)

    4. 选中项目 ---->maven--->update project

  • 相关阅读:
    BZOJ 4260 Codechef REBXOR
    [SHOI2008]小约翰的游戏John
    [POI2016]Nim z utrudnieniem
    [CQOI2013]棋盘游戏
    [SDOI2016]硬币游戏
    [BZOJ3083]遥远的国度
    [Luogu3727]曼哈顿计划E
    [HihoCoder1413]Rikka with String
    [CF666E]Forensic Examination
    [BZOJ4004][JLOI2015]装备购买
  • 原文地址:https://www.cnblogs.com/nuoyinsomnus/p/7880325.html
Copyright © 2011-2022 走看看