欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Eclipse中使用Maven創(chuàng)建Java Web工程的實現(xiàn)方式

 更新時間:2017年10月30日 11:17:18   作者:旭旭同學(xué)  
這篇文章主要介紹了Eclipse中使用Maven創(chuàng)建Java Web工程的實現(xiàn)方式的相關(guān)資料,希望通過本文能幫助到大家,讓大家實現(xiàn)這樣的方式,需要的朋友可以參考下

Eclipse中使用Maven創(chuàng)建Java Web工程的實現(xiàn)方式

1)在Eclipse項目欄中右鍵單擊空白,New(或直接使用Ctrl+N快捷鍵) —— Other ——Maven Project。

2)選擇以webapp模板創(chuàng)建工程

3)填寫Group Id 、 Artifact Id 等信息。

groupId

定義了項目屬于哪個組,舉個例子,如果你的公司是mycom,有一個項目為myapp,那么groupId就應(yīng)該是com.mycom.myapp.

artifacted

定義了當(dāng)前maven項目在組中唯一的ID,比如,myapp-util,myapp-domain,myapp-web等。

version

指定了myapp項目的當(dāng)前版本,SNAPSHOT意為快照,說明該項目還處于開發(fā)中,是不穩(wěn)定的版本。

4)創(chuàng)建完成之后,有的電腦會提示Servelet相關(guān)的包沒有被導(dǎo)入。這個我們可以統(tǒng)一在POM.XML文件中統(tǒng)一去寫。pom.xml里面的依賴可以在http://mvnrepository.com/ 這個網(wǎng)站上去查找,該站點已經(jīng)幫你把依賴按格式寫好,十分方便。下面給出一份我以前做練手項目所用的pom.xml文件。

<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>
  <groupId>org.seckill</groupId>
  <artifactId>seckill</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>seckill Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <!-- 使用junit4注解方式 -->
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <!-- 補全項目依賴 -->
    <!-- 1:日志 java日志:slf4,log4j,logback slf4j是 規(guī)范、接口 日志實現(xiàn):log4j、logback -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.12</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.1.1</version>
    </dependency>
    <!-- 實現(xiàn)slf4j接口并整合 -->

    <!-- 2:數(shù)據(jù)庫相關(guān)依賴 -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.35</version>
      <scope>runtime</scope>
    </dependency>
    <!-- 數(shù)據(jù)庫連接池 -->
    <dependency>
      <groupId>c3p0</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.1.2</version>
    </dependency>

    <!-- DAO框架依賴:MyBatis依賴 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.3.0</version>
    </dependency>
    <!-- MyBatis自身實現(xiàn)的Spring整合依賴 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.3</version>
    </dependency>

    <!-- 3:Servlet Web相關(guān)依賴 -->
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.5.4</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
    </dependency>

    <!-- 4:Spring依賴 -->
    <!-- 1)Spring核心依賴 -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <!-- 2)Spring dao層 -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <!-- 3)Spring web依賴 -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <!-- 4)Spring test相關(guān)的依賴 -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>4.1.7.RELEASE</version>
    </dependency>
    <!-- redis客戶端:Jedis -->
    <dependency>
      <groupId>redis.clients</groupId>
      <artifactId>jedis</artifactId>
      <version>2.7.3</version>
    </dependency>
    <!-- protostuff序列化 -->
    <dependency>
      <groupId>com.dyuproject.protostuff</groupId>
      <artifactId>protostuff-core</artifactId>
      <version>1.0.8</version>
    </dependency>
    <dependency>
      <groupId>com.dyuproject.protostuff</groupId>
      <artifactId>protostuff-runtime</artifactId>
      <version>1.0.8</version>
    </dependency>
    <!-- collections集合框架工具 -->
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>

  </dependencies>
  <build>
    <finalName>seckill</finalName>
  </build>
</project>

5)注意web.xml中要開啟標(biāo)簽庫和EL表達(dá)式支持,要用2.3以上版本,所以把xml頭部的都改掉

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
           http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1" metadata-complete="true">

6)maven 項目的src/main/java 和 src/main/resources 都是項目根目錄(classpath:)。例如,想訪問src/main/resources 目錄下的mybatis-config.xml,它的路徑參數(shù)要寫成(“mybatis-config.xml”)。

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

  • 解決java啟動時報線程占用報錯:Exception?in?thread?“Thread-14“?java.net.BindException:?Address?already?in?use:?bind

    解決java啟動時報線程占用報錯:Exception?in?thread?“Thread-14“?java.ne

    這篇文章主要給大家介紹了關(guān)于解決java啟動時報線程占用:Exception?in?thread?“Thread-14“?java.net.BindException:?Address?already?in?use:?bind的相關(guān)資料,文中將解決的辦法介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • java 中平方根(sqrt)算法 的實例詳解

    java 中平方根(sqrt)算法 的實例詳解

    這篇文章主要介紹了java 中平方根(sqrt)算法 的實例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • Java注解的Retention和RetentionPolicy實例分析

    Java注解的Retention和RetentionPolicy實例分析

    這篇文章主要介紹了Java注解的Retention和RetentionPolicy,結(jié)合實例形式分析了Java注解Retention和RetentionPolicy的基本功能及使用方法,需要的朋友可以參考下
    2019-09-09
  • spring?boot?使用Mybatis-plus查詢方法解析

    spring?boot?使用Mybatis-plus查詢方法解析

    這篇文章主要介紹了spring?boot?使用Mybatis-plus查詢方法解析,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-09-09
  • java對象拷貝詳解及實例

    java對象拷貝詳解及實例

    這篇文章主要介紹了java對象拷貝詳解及實例的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • Spring Boot中單例類實現(xiàn)對象的注入方式

    Spring Boot中單例類實現(xiàn)對象的注入方式

    這篇文章主要介紹了Spring Boot中單例類實現(xiàn)對象的注入方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-08-08
  • 詳解使用MyBatis Generator自動創(chuàng)建代碼

    詳解使用MyBatis Generator自動創(chuàng)建代碼

    這篇文章主要介紹了使用MyBatis Generator自動創(chuàng)建代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • 詳解java面試題中的i++和++i

    詳解java面試題中的i++和++i

    這篇文章主要介紹了java面試題中的i++和++i的相關(guān)資料,需要的朋友可以參考下
    2018-03-03
  • SpringBoot中Json工具類的實現(xiàn)

    SpringBoot中Json工具類的實現(xiàn)

    本文介紹在Java項目中實現(xiàn)一個JSON工具類,支持對象與JSON字符串之間的轉(zhuǎn)換,并提供依賴和代碼示例便于直接應(yīng)用,感興趣的可以了解一下
    2024-10-10
  • Java手寫簡易版HashMap的使用(存儲+查找)

    Java手寫簡易版HashMap的使用(存儲+查找)

    這篇文章主要介紹了Java手寫簡易版HashMap的使用(存儲+查找),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01

最新評論