2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

Maven下,spring+struts2+ibatis整合

 昵稱16968929 2014-04-24
一、Maven的安裝配置
參考此博客:http://qincao./blog/614022
PS:很簡潔易懂,引用一下,呵呵

二、使用maven構建多工程
1、通過cmd,進入Dos下執(zhí)行mvn創(chuàng)建指令
2、創(chuàng)建主工程,假設在E盤創(chuàng)建
Java代碼  收藏代碼
  1. mvn archetype:create -DgroupId=com.cy -DartifactId=mallshop -Dversion=1.0  

備注:
  • <groupId>:一個項目群的ID,一個項目群可以包含多個項目
  • <artifactId>:一個項目的ID,是每個項目的唯一ID.
  • <version>:描述了項目當前的版本.
需要注意,必須修改pom.xml,參考錯誤一的解決方法

3、進入主工程下(Dos下執(zhí)行cd E:\mallshop進入),創(chuàng)建多個子工程,如下:
Java代碼  收藏代碼
  1. mvn archetype:create -DgroupId=com.cy.biz.dal -DartifactId=mallshop-biz-dal -Dversion=1.0  
  2. mvn archetype:create -DgroupId=com.cy.biz.core -DartifactId=mallshop-biz-core -Dversion=1.0  
  3. mvn archetype:create -DgroupId=com.cy.biz.manager -DartifactId=mallshop-biz-manager -Dversion=1.0  
  4. mvn archetype:create -DgroupId=com.cy.web -DartifactId=mallshop-web -Dversion=1.0 -DarchetypeArtifactId=maven-archetype-webapp  

 
引用
其中修改的重點為打包方式(war/jar)改為pom形式,這也就意味這這是一個父工程,另外版本號默認是SNAPSHOT意思是快照的意思,就是項目開發(fā)中的意思,你要是看著不爽可以把它刪掉,另外需要說明一下dependencyManagement標簽,這個標簽表示子類可以隱式的繼承父pom文件的依賴庫,在子pom中不需要指定版本號,推薦這樣,這樣可以方便開發(fā),你要修改什么依賴的版本只需要更改父pom就可以了,dependencies是顯示繼承,你要是在子pom中聲明,就必須寫明版本號,不寫默認就繼承了。


4、修改各個pom,添加相關依賴
Java代碼  收藏代碼
  1.    
  2.  <dependency>  
  3. <groupId>com.cy.biz.dal</groupId>  
  4. <artifactId>cy-biz-dal</artifactId>  
  5. <version>${project.version}</version>  
  6.  </dependency>  


5、將Maven項目轉為Eclipse項目
具體操作為將dos命令窗口切換到Maven項目的目錄下,輸入命令:
mvn eclipse:eclipse

6、導入eclipse
  • 在該項目上點右鍵Maven->Enable
  • 在該項目上點右鍵Build Path->Configure Build Path->Java Build Path->Libraries->去掉Maven添加的變量路徑
  • 在該項目上點右鍵MyEclipse->Add Web Capabilities->修改Web root地址(點【瀏覽】按鈕指定為當前工作空間下的src/main/webapp文件夾)
  • 配置完畢,可以用MyEclipse插件配置服務器等開始正常開發(fā),自動部署,調試等操作了。


三、整合ssi
1、在主工程下的pom.xml中添加相應的配置,完整如下
Java代碼  收藏代碼
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project xmlns="http://maven./POM/4.0.0" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://maven./POM/4.0.0 http://maven./maven-v4_0_0.xsd">  
  3.   <modelVersion>4.0.0</modelVersion>  
  4.   <groupId>com.cy</groupId>  
  5.   <artifactId>mallshop</artifactId>  
  6.   <packaging>pom</packaging>  
  7.   <version>1.0</version>  
  8.   <name>mallshop</name>  
  9.   <url>http://maven.</url>  
  10.  <dependencies>  
  11.    <dependency>  
  12.             <groupId>junit</groupId>  
  13.             <artifactId>junit</artifactId>  
  14.             <version>4.7</version>  
  15.             <scope>test</scope>  
  16.         </dependency>  
  17.              <dependency>  
  18.             <groupId>log4j</groupId>  
  19.             <artifactId>log4j</artifactId>  
  20.             <version>1.2.14</version>  
  21.         </dependency>  
  22.         <dependency>  
  23.             <groupId>commons-dbcp</groupId>  
  24.             <artifactId>commons-dbcp</artifactId>  
  25.             <version>1.2.2</version>  
  26.         </dependency>  
  27.         <dependency>  
  28.             <groupId>commons-beanutils</groupId>  
  29.             <artifactId>commons-beanutils</artifactId>  
  30.             <version>1.7.0</version>  
  31.         </dependency>  
  32.         <dependency>  
  33.             <groupId>org.springframework</groupId>  
  34.             <artifactId>spring-mock</artifactId>  
  35.             <version>2.0.8</version>  
  36.         </dependency>  
  37.         <dependency>  
  38.             <groupId>org.springframework</groupId>  
  39.             <artifactId>spring-webmvc</artifactId>  
  40.             <version>2.5.6</version>  
  41.         </dependency>  
  42.         <dependency>  
  43.             <groupId>mysql</groupId>  
  44.             <artifactId>mysql-connector-java</artifactId>  
  45.             <version>5.1.9</version>  
  46.         </dependency>  
  47.         <dependency>  
  48.             <groupId>org.springframework</groupId>  
  49.             <artifactId>spring</artifactId>  
  50.             <version>2.5.6</version>  
  51.         </dependency>  
  52.             <dependency>  
  53.             <groupId>org.apache.ibatis</groupId>  
  54.             <artifactId>ibatis-sqlmap</artifactId>  
  55.             <version>2.3.4.726</version>  
  56.         </dependency>  
  57.         <dependency>  
  58.             <groupId>javax.servlet</groupId>  
  59.             <artifactId>servlet-api</artifactId>  
  60.             <version>2.4</version>  
  61.         </dependency>  
  62.         <dependency>  
  63.             <groupId>javax.mail</groupId>  
  64.             <artifactId>mail</artifactId>  
  65.             <version>1.4.1</version>  
  66.         </dependency>  
  67.         <dependency>  
  68.       <groupId>org.apache.struts</groupId>  
  69.       <artifactId>struts2-jfreechart-plugin</artifactId>  
  70.     <version>2.1.8</version>  
  71.     </dependency>  
  72.   </dependencies>  
  73.   <build>  
  74.         <plugins>  
  75.             <plugin>  
  76.                 <groupId>org.apache.maven.plugins</groupId>  
  77.                 <artifactId>maven-compiler-plugin</artifactId>  
  78.                 <configuration>  
  79.                     <source>1.6</source>  
  80.                     <target>1.6</target>   
  81.                     <encoding>GBK</encoding>  
  82.                 </configuration>  
  83.             </plugin>  
  84.         </plugins>  
  85.     </build>  
  86.   <modules>  
  87.     <module>mallshop-biz-dal</module>  
  88.     <module>mallshop-biz-core</module>  
  89.     <module>mallshop-biz-manager</module>  
  90.     <module>mallshop-web</module>  
  91.   </modules>  
  92. </project>    

PS:具體根據(jù)自己的需要

2、執(zhí)行如下mvn指令,完成
  mvn install
  mvn clean
  mvn eclipse:eclipse
  mvn clean package -Dmaven.test.skip=true;
  執(zhí)行下載
  mvn eclipse:clean eclipse:eclipse -DdownloadSources=true

3、Bingo!整合完畢??!

在此過程中遇到錯誤整理:


1、未執(zhí)行如下操作,就創(chuàng)建子工程,會報這樣的錯誤:

引用
Embedded error: Unable to add module to the current project as it is not of packaging type 'pom'

解決方案:
修改主工程目錄下的pom文件,設置如下:
<packaging>pom</packaging>

2、source 1.3 中不支持泛型
maven打包時始終出現(xiàn)以下提示:

引用
1、-source 1.3 中不支持泛型(請使用 -source 5 或更高版本以啟用泛型)List<User> userList= new ArrayList<User>();

2、-source 1.3 中不支持注釋(請使用 -source 5 或更高版本以啟用注釋)@WebService(endpointInterface = "com.webservice.service.LoadService")


解決辦法:
用命令mvn -v查看結果:
引用
C:\Users\Administrator>mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0
Java home: D:\Program Files\Java\jdk1.6.0\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows vista" version: "6.1" arch: "x86" Family: "windows"

PS:顯然與所配置的JDK無關。

最終解決辦法:

在項目的pom.xml(放在主工程下的)中,添加   
Java代碼  收藏代碼
  1. <build>  
  2.     <plugins>  
  3.       <plugin>  
  4.         <groupId>org.apache.maven.plugins</groupId>  
  5.         <artifactId>maven-compiler-plugin</artifactId>  
  6.         <configuration>  
  7.           <source>1.5</source>  
  8.           <target>1.5</target>  
  9.         </configuration>  
  10.       </plugin>  
  11.     </plugins>  
  12. </build>   


再執(zhí)行mvn install,OK。

3、新建的類中,右擊,執(zhí)行相應操作,會出現(xiàn)如下提示框:


原因是找不到路徑,具體的操作方式如下:
在web工程中新建Source Folder,取名為src/main/resources或src/main/java,然后新建package,在此包下創(chuàng)建class;在src->main中新建Folder,取名為webconfig,存放spring配置文件  

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多