1、spingIOC+IDEA+Maven

来源:https://www.cnblogs.com/holly8/archive/2022/08/18/spingIOC_IDEA_Maven.html
-Advertisement-
Play Games

1、先配置spring、springmvc通用xml文件的頭部信息 spring、springmvc通用xml文件的模板內容如下: 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework. ...


1、先配置spring、springmvc通用xml文件的頭部信息

spring、springmvc通用xml文件的模板內容如下:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4        xmlns:aop="http://www.springframework.org/schema/aop"
 5        xmlns:context="http://www.springframework.org/schema/context"
 6        xmlns:tx="http://www.springframework.org/schema/tx"
 7        xmlns:mvc="http://www.springframework.org/schema/mvc"
 8        xsi:schemaLocation="http://www.springframework.org/schema/beans
 9        http://www.springframework.org/schema/beans/spring-beans.xsd
10        http://www.springframework.org/schema/aop
11        http://www.springframework.org/schema/aop/spring-aop.xsd
12        http://www.springframework.org/schema/context
13        http://www.springframework.org/schema/context/spring-context.xsd
14        http://www.springframework.org/schema/tx
15        http://www.springframework.org/schema/tx/spring-tx.xsd
16        http://www.springframework.org/schema/mvc
17        http://www.springframework.org/schema/mvc/spring-mvc.xsd
18 ">
19    
20 </beans>
spring、springmvc文件通用內容

 

 

 

spring、spring

 

 

 

 

 

 

 

 

 2、構建spring的第一個工程

 

 

 

 

 

 

 

 

 

 

 

 

 3、配置項目中的pom.xml文件依賴

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 
  3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5   <modelVersion>4.0.0</modelVersion>
  6 
  7   <groupId>com</groupId>
  8   <artifactId>springmybatis_day44_02</artifactId>
  9   <version>1.0-SNAPSHOT</version>
 10   <packaging>war</packaging>
 11 
 12   <name>springmybatis_day44_02 Maven Webapp</name>
 13   <!-- FIXME change it to the project's website -->
 14   <url>http://www.example.com</url>
 15 
 16   <properties>
 17     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 18     <maven.compiler.source>1.7</maven.compiler.source>
 19     <maven.compiler.target>1.7</maven.compiler.target>
 20   </properties>
 21 
 22 
 23   <dependencies>
 24 
 25     <dependency>
 26       <groupId>junit</groupId>
 27       <artifactId>junit</artifactId>
 28       <version>4.11</version>
 29     </dependency>
 30 
 31     <!--1 https://mvnrepository.com/artifact/org.springframework/spring-beans -->
 32     <dependency>
 33       <groupId>org.springframework</groupId>
 34       <artifactId>spring-beans</artifactId>
 35       <version>4.3.6.RELEASE</version>
 36     </dependency>
 37 
 38 
 39     <!--2 https://mvnrepository.com/artifact/org.springframework/spring-context -->
 40     <dependency>
 41       <groupId>org.springframework</groupId>
 42       <artifactId>spring-context</artifactId>
 43       <version>4.3.6.RELEASE</version>
 44     </dependency>
 45 
 46 
 47     <!-- 3https://mvnrepository.com/artifact/org.springframework/spring-core -->
 48     <dependency>
 49       <groupId>org.springframework</groupId>
 50       <artifactId>spring-core</artifactId>
 51       <version>4.3.6.RELEASE</version>
 52     </dependency>
 53 
 54 
 55     <!--4 https://mvnrepository.com/artifact/org.springframework/spring-expression -->
 56     <dependency>
 57       <groupId>org.springframework</groupId>
 58       <artifactId>spring-expression</artifactId>
 59       <version>4.3.6.RELEASE</version>
 60     </dependency>
 61 
 62 
 63     <!--5 https://mvnrepository.com/artifact/org.springframework/spring-aop -->
 64     <dependency>
 65       <groupId>org.springframework</groupId>
 66       <artifactId>spring-aop</artifactId>
 67       <version>4.3.6.RELEASE</version>
 68     </dependency>
 69 
 70 
 71     <!--6 https://mvnrepository.com/artifact/aopalliance/aopalliance -->
 72     <dependency>
 73       <groupId>aopalliance</groupId>
 74       <artifactId>aopalliance</artifactId>
 75       <version>1.0</version>
 76     </dependency>
 77 
 78 
 79     <!--7 https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
 80     <dependency>
 81       <groupId>org.aspectj</groupId>
 82       <artifactId>aspectjweaver</artifactId>
 83       <version>1.8.10</version>
 84     </dependency>
 85 
 86 
 87     <!--8 https://mvnrepository.com/artifact/log4j/log4j -->
 88     <dependency>
 89       <groupId>log4j</groupId>
 90       <artifactId>log4j</artifactId>
 91       <version>1.2.17</version>
 92     </dependency>
 93 
 94 
 95     <!--9 https://mvnrepository.com/artifact/commons-logging/commons-logging -->
 96     <dependency>
 97       <groupId>commons-logging</groupId>
 98       <artifactId>commons-logging</artifactId>
 99       <version>1.2</version>
100     </dependency>
101 
102 
103     <!--10 https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
104     <dependency>
105       <groupId>org.springframework</groupId>
106       <artifactId>spring-jdbc</artifactId>
107       <version>4.3.6.RELEASE</version>
108     </dependency>
109 
110 
111     <!--11 https://mvnrepository.com/artifact/org.springframework/spring-orm -->
112     <dependency>
113       <groupId>org.springframework</groupId>
114       <artifactId>spring-orm</artifactId>
115       <version>4.3.6.RELEASE</version>
116     </dependency>
117 
118 
119     <!--12 https://mvnrepository.com/artifact/org.springframework/spring-tx -->
120     <dependency>
121       <groupId>org.springframework</groupId>
122       <artifactId>spring-tx</artifactId>
123       <version>4.3.6.RELEASE</version>
124     </dependency>
125 
126 
127     <!--13 https://mvnrepository.com/artifact/org.springframework/spring-web -->
128     <dependency>
129       <groupId>org.springframework</groupId>
130       <artifactId>spring-web</artifactId>
131       <version>4.3.6.RELEASE</version>
132     </dependency>
133 
134 
135     <!--14 https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
136     <dependency>
137       <groupId>org.springframework</groupId>
138       <artifactId>spring-webmvc</artifactId>
139       <version>4.3.6.RELEASE</version>
140     </dependency>
141 
142 
143     <!--15 https://mvnrepository.com/artifact/org.mybatis/mybatis -->
144     <dependency>
145       <groupId>org.mybatis</groupId>
146       <artifactId>mybatis</artifactId>
147       <version>3.4.6</version>
148     </dependency>
149 
150     <!--17 https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
151     <dependency>
152       <groupId>org.mybatis</groupId>
153       <artifactId>mybatis-spring</artifactId>
154       <version>1.3.2</version>
155     </dependency>
156 
157 
158     <!--16 https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
159     <dependency>
160       <groupId>mysql</groupId>
161       <artifactId>mysql-connector-java</artifactId>
162       <version>5.1.38</version>
163     </dependency>
164 
165 
166     <!--18 https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
167     <dependency>
168       <groupId>javax.servlet</groupId>
169       <artifactId>javax.servlet-api</artifactId>
170       <version>3.1.0</version>
171     </dependency>
172 
173     <!--19 https://mvnrepository.com/artifact/javax.servlet/jstl -->
174     <dependency>
175       <groupId>javax.servlet</groupId>
176       <artifactId>jstl</artifactId>
177       <version>1.2</version>
178     </dependency>
179 
180 
181     <!--20 https://mvnrepository.com/artifact/taglibs/standard -->
182     <dependency>
183       <groupId>taglibs</groupId>
184       <artifactId>standard</artifactId>
185       <version>1.1.2</version>
186     </dependency>
187 
188   </dependencies>
189 
190 
191 </project>
pom.xml

4、在項目的main下創建java和resouces目錄

 

5、將java目錄變為編譯目錄

 

 

6、將resources目錄變為存放xml腳本的目錄

 

 

 

 

 7、在java的com.pojo包下構建Student和Classes兩個類 

 1 package com.pojo;
 2 
 3 public class Classes {
 4     private Integer cid;
 5     private String cname;
 6 
 7     public Classes() {
 8     }
 9 
10     public Classes(Integer cid, String cname) {
11         this.cid = cid;
12         this.cname = cname;
13     }
14 
15     public Integer getCid() {
16         return cid;
17     }
18 
19     public void setCid(Integer cid) {
20         this.cid = cid;
21     }
22 
23     public String getCname() {
24         return cname;
25     }
26 
27     public void setCname(String cname) {
28         this.cname = cname;
29     }
30 
31     @Override
32     public String toString() {
33         return "Classes{" +
34                 "cid=" + cid +
35                 ", cname='" + cname + '\'' +
36                 '}';
37     }
38 }
Classes.java
 1 package com.pojo;
 2 
 3 public class Student {
 4     private Integer sid;
 5     private String sname;
 6     private String course;
 7     private Double score;
 8 
 9     private Classes classes;
10 
11     public Student() {
12     }
13 
14     public Student(Integer sid, String sname, String course, Double score, Classes classes) {
15         this.sid = sid;
16         this.sname = sname;
17         this.course = course;
18         this.score = score;
19         this.classes = classes;
20     }
21 
22     public Integer getSid() {
23         return sid;
24     }
25 
26     public void setSid(Integer sid) {
27         this.sid = sid;
	   

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 4. 業務層 4.1 MVC模型 MVC:Model(模型),View(視圖),Controller(控制器) 視圖層:用於做數據的展示以及和用戶交互的一個界面=>jsp 控制層:能夠接受客戶端的請求並且進行請求轉發,具體的業務功能還是需要藉助模型層組件來完成。CoreServlet => Disp ...
  • Json格式在後臺服務中的重要性就不多說了,直入正題。首先引入pom文件,這裡使用的是1.2.83版本 1 <dependency> 2 <groupId>com.alibaba</groupId> 3 <artifactId>fastjson</artifactId> 4 <version>1.2 ...
  • 如題:使用三個線程交替列印ABC,直至100次代碼實戰 方法一: 使用notify()、wait()方法 public class PrintAbc { /** * 喚醒線程的狀態值 state: threadA = 0, threadB = 1, threadC =2, */ int state ...
  • 爬取 flbook 文檔 需求介紹 由於實習期間被主管委派了下載下來《安徽省助企政策彙編》的任務,去大概搜索瞭解了一下 flbook 網站,發現該網站並不提供已經發佈的文檔的下載渠道(感覺挺莫名其妙的,都公開允許觀看了,為什麼不給下載渠道啊,更何況還是個政府文件,發佈在這種網站上,總覺得哪裡有問題) ...
  • 目錄 一.簡介 二.效果演示 三.源碼下載 四.猜你喜歡 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 基礎 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 轉場 零基礎 O ...
  • 0. 標簽順序 Mybatis核心配置文件中有很多標簽,它們誰誰寫在前寫在後其實是:boom:有順序:boom:要求的: 從前到後: properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactor ...
  • 2.函數的遞歸的定義 函數的遞歸調用:是函數嵌套調用的一種特殊形式 具體是指:在調用一個函數的過程中又直接或者間接的調用到本身,是一個死迴圈,最大遞歸是1000次,超出之後報錯。 2.函數遞歸的調用 # 直接調本身 def f1(): print('是我還是我') f1() f1() # 間接調用 ...
  • 當我們拿到一個對象的引用時,如何知道這個對象是什麼類型、有哪些方法呢? 1.使用type() 首先,我們來判斷對象類型,使用type()函數: 基本類型都可以用type()判斷: >>> type(123) <class 'int'> >>> type('str') <class 'str'> >> ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...