免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開(kāi)通VIP
IDEA創(chuàng)建Maven項(xiàng)目

前言

一些小問(wèn)題:
關(guān)于maven無(wú)法創(chuàng)建servlet可以點(diǎn)擊查看:《idea 的maven無(wú)法創(chuàng)建servlet》


先創(chuàng)建一個(gè)maven工程,流程如下:





以上maven工程創(chuàng)建完成了。

Maven使用入門,小案例

  1. 按照以上步驟,創(chuàng)建的maven工程,結(jié)構(gòu)如下:

  2. maven目錄結(jié)構(gòu)里面缺少了Java源文件夾,需要我們手動(dòng)添加上去,過(guò)程如下:

    先新建目錄



3.再將新建的文件設(shè)置為源文件

4.在java新建包,再在包里新建一個(gè)servlet,關(guān)于maven無(wú)法創(chuàng)建servlet,可以參考前言里的解決辦法進(jìn)行相應(yīng)設(shè)置,

項(xiàng)目的結(jié)構(gòu)如圖:


servlet代碼如下:

package aa.bb;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet("/testServlet")public class TestServlet extends HttpServlet {protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.getRequestDispatcher("/test.jsp").forward(request, response);    }    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {doPost(request, response);    }}

jsp代碼如下:

<%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head>    <title>Title</title></head><body>hello!!!Maven</body></html>

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/maven-v4_0_0.xsd">  <modelVersion>4.0.0</modelVersion>  <packaging>war</packaging>  <name>maven1</name>  <groupId>org.example</groupId>  <artifactId>maven1</artifactId>  <version>1.0-SNAPSHOT</version>  <!--放置的都是項(xiàng)目運(yùn)行所依賴的jar包-->  <dependencies><!--    <dependency>--><!--      <groupId>javax.servlet</groupId>--><!--      <artifactId>servlet-api</artifactId>--><!--      <version>2.5</version>--><!--      <scope>provided</scope>--><!--    </dependency>-->    <!--jsp-->    <dependency>      <groupId>javax.servlet.jsp</groupId>      <artifactId>jsp-api</artifactId>      <version>2.2</version>      <scope>provided</scope>    </dependency>    <!--junit-->    <dependency>      <groupId>junit</groupId>      <artifactId>junit</artifactId>      <version>4.12</version>      <scope>test</scope>    </dependency>    <!--servlrt-->    <dependency>      <groupId>javax.servlet</groupId>      <artifactId>javax.servlet-api</artifactId>      <version>4.0.0</version>      <scope>provided</scope>    </dependency>  </dependencies>  <build>    <plugins>      <!--配置tomcat-->      <plugin>        <groupId>org.apache.tomcat.maven</groupId>        <artifactId>tomcat7-maven-plugin</artifactId>        <version>2.2</version>        <configuration>          <port>8089</port>        </configuration>      </plugin>      <!--配置jdk-->      <plugin>        <groupId>org.apache.maven.plugins</groupId>        <artifactId>maven-compiler-plugin</artifactId>        <configuration>          <target>1.8</target>          <source>1.8</source>          <encoding>UTF-8</encoding>        </configuration>      </plugin>    </plugins>  </build></project>


運(yùn)行結(jié)果:

來(lái)源:https://www.icode9.com/content-4-882551.html
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Intellij8中Maven打包時(shí)jsp和servlet組件沖突解決辦法
正確配置jstl的maven依賴,jar包沖突的問(wèn)題終于解決啦
Maven管理依賴
meavn-pom坐標(biāo)
如何查看 JSP 和 Servlet 的版本
【教程】IDEA創(chuàng)建Maven項(xiàng)目并整合Tomcat發(fā)布,問(wèn)題解決大全
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服