---
# System prepended metadata

title: Spring 2/23 從0開始建立專案
tags: [Spring]

---

# Spring 2/23 從0開始建立專案
###### tags: `Spring`

[老師云端](https://1drv.ms/u/s!Ans47I9-PkivwFaYGiqWCMQTAylZ)
# JDK11(建議用)

![](https://i.imgur.com/OnrworC.png)

![](https://i.imgur.com/KNb5rWM.png)
### 環境變數
![](https://i.imgur.com/d4RvToJ.png)

![](https://i.imgur.com/exa4QBQ.png)
### cmd
![](https://i.imgur.com/yrLyMms.png)

![](https://i.imgur.com/fGyrPKF.png)
![](https://i.imgur.com/gJUO53W.png)
![](https://i.imgur.com/wjZJIvw.png)
![](https://i.imgur.com/9r6IOvN.png)
![](https://i.imgur.com/lZVdkmD.png)
![](https://i.imgur.com/C0BaPVO.png)
![](https://i.imgur.com/3wfLdDU.png)
### 編碼
![](https://i.imgur.com/qHO7kgc.png)
### 字體
![](https://i.imgur.com/HMyKhOW.png)
### 總編碼
![](https://i.imgur.com/3HjQy1H.png)
### a-z
.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
![](https://i.imgur.com/eBbJz67.png)

### maven
![](https://i.imgur.com/l8NtB1v.png)
![](https://i.imgur.com/fu1EDHJ.png)

###  maven
![](https://i.imgur.com/rcsEvLd.png)
![](https://i.imgur.com/hsdoUw1.png)

### 變數
![](https://i.imgur.com/PLVKki3.png)

### cmd
![](https://i.imgur.com/6G8JYhQ.png)

### 開啟檔案
![](https://i.imgur.com/52tGwzQ.png)
![](https://i.imgur.com/hlDas4F.png)
![](https://i.imgur.com/lQbMsJ6.png)  <localRepository>C:\DataSource\maven_repository\repository</localRepository>
![](https://i.imgur.com/SU3VWKi.png)
maven_repository
![](https://i.imgur.com/yZF5UiJ.png)
repository

### 複製
![](https://i.imgur.com/TVC9Isd.png)
![](https://i.imgur.com/mZdhzBX.png)

### mavne
![](https://i.imgur.com/JxkKiQ8.png)
![](https://i.imgur.com/xdSZfKV.png)
![](https://i.imgur.com/iLq4CXX.png)
![](https://i.imgur.com/WQPmDpV.png)

### pom
[maven jdbc](https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc/8.4.1.jre11)

```clike=
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>JavaProject</groupId>
  <artifactId>JavaProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  
  <dependencies>
	 <dependency>
	    <groupId>com.microsoft.sqlserver</groupId>
	    <artifactId>mssql-jdbc</artifactId>
	    <version>8.4.1.jre11</version>
	</dependency>
  </dependencies>
  
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
```

alt+f5 (重新整理)
![](https://i.imgur.com/OS1Ucuh.png)


![](https://i.imgur.com/uawtFsZ.png)
![](https://i.imgur.com/6VMd0xu.png)
alt+f5

### tomcat
![](https://i.imgur.com/eGnj5qQ.png)
![](https://i.imgur.com/nzJOEO1.png)
![](https://i.imgur.com/ttDRhRQ.png)
![](https://i.imgur.com/A7NG5Mr.png)
![](https://i.imgur.com/x6VC5rJ.png)
[他母貓](http://localhost:8080/)

### tomcat
![](https://i.imgur.com/VfdIRIU.png)
![](https://i.imgur.com/FYMMKlg.png)

###
![](https://i.imgur.com/qv83dOJ.png)

![](https://i.imgur.com/q8wKq1Y.png)

![](https://i.imgur.com/HFWNL2b.png)

[hibernate](https://hibernate.org/orm/releases/)

![](https://i.imgur.com/PlG5y4D.png)
![](https://i.imgur.com/muFwAjb.png)
![](https://i.imgur.com/N7PZvpu.png)
![](https://i.imgur.com/boHEFPm.png)
* 都下一步 然後完成 不要調皮亂按
中間過程都按同意 
![](https://i.imgur.com/AYSFw7Z.png)

### 
![](https://i.imgur.com/OLwaC6g.jpg)
![](https://i.imgur.com/3J0U0CF.png)
![](https://i.imgur.com/cA8FlTj.png)
sql.jdbc
![](https://i.imgur.com/vET7xcC.png)


![](https://i.imgur.com/eXBMvyN.png)
jdbc:sqlserver://localhost:8080;databaseName=LeonPower

watcher
P@ssw0rd

xml
![](https://i.imgur.com/LQyTpxp.png)
```clike=
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
		"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.password">P@ssw0rd</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=LeonPower</property>
        <property name="hibernate.connection.username">watcher</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.format_sql">true</property>
    </session-factory>
</hibernate-configuration>
```

### 懶人用法
![](https://i.imgur.com/nzMCnMW.png)

### sql
![](https://i.imgur.com/5LWFeFr.png)
watcher
P@ssw0rd
![](https://i.imgur.com/84qa0OH.png)
![](https://i.imgur.com/jfqAqNs.png)
勾那個就能得到全部

xml ->1433
![](https://i.imgur.com/gRGblUf.png)

[hibernate](https://mvnrepository.com/artifact/org.hibernate/hibernate-core)
[jar](https://mvnrepository.com/search?q=hibernate)
### pom.xml
``` click=
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>JavaProject</groupId>
  <artifactId>JavaProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  
  <dependencies>
	 <dependency>
	    <groupId>com.microsoft.sqlserver</groupId>
	    <artifactId>mssql-jdbc</artifactId>
	    <version>8.4.1.jre11</version>
	</dependency>
	
	<dependency>
	    <groupId>org.hibernate</groupId>
	    <artifactId>hibernate-core</artifactId>
	    <version>5.4.28.Final</version>
	</dependency>
	
  </dependencies>
  
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
```
![](https://i.imgur.com/eb7hPnD.png)


### 備份
![](https://i.imgur.com/PsFGwcl.png)
![](https://i.imgur.com/KCn4Rhc.png)



### Spring
[Spring](https://github.com/spring-projects/toolsuite-distribution/wiki/Spring-Tool-Suite-3)
4->3
![](https://i.imgur.com/a2g5wmu.png)

![](https://i.imgur.com/JBExqUg.png)

### 
![](https://i.imgur.com/HDZCUSX.png)
![](https://i.imgur.com/eI32X5C.png)
![](https://i.imgur.com/ObuE48t.png)


### 
[Index of release/org/springframework/spring/5.3.4](https://repo.spring.io/release/org/springframework/spring/5.3.4/)

![](https://i.imgur.com/HXfG31M.png)

### pom.xml
![](https://i.imgur.com/Hki2Cq7.png)

```clike=
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>JavaProject</groupId>
	<artifactId>JavaProject</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<dependencies>
		<dependency>
			<groupId>com.microsoft.sqlserver</groupId>
			<artifactId>mssql-jdbc</artifactId>
			<version>8.4.1.jre11</version>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>5.4.28.Final</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>5.3.4</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>5.3.4</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>5.3.4</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
			<version>5.3.4</version>
		</dependency>

		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.2</version>
		</dependency>
	</dependencies>


	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
				<configuration>
					<release>11</release>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
```

### +jar檔(另一種方式可不做)
![](https://i.imgur.com/BSuPj2i.png)
![](https://i.imgur.com/6nPRvIt.png)
![](https://i.imgur.com/yDcZdIb.png)
![](https://i.imgur.com/jcDBF64.png)
![](https://i.imgur.com/QOaHlfp.png)
![](https://i.imgur.com/MdlOzCV.png)
![](https://i.imgur.com/jmZQmb8.png)

### 組態檔
![](https://i.imgur.com/3osb5C0.png)

![](https://i.imgur.com/ZLxWEnH.png)
![](https://i.imgur.com/HrTnhTn.png)
![](https://i.imgur.com/b3zl6aj.png)
![](https://i.imgur.com/S5N3MrR.png)
選沒有版本的規格
end

如果沒改道
![](https://i.imgur.com/Ukyv9XF.png)

### class
![](https://i.imgur.com/pi0Sr0C.png)
### beans.config.xml組態檔
![](https://i.imgur.com/H5wPgHz.png)
![](https://i.imgur.com/FaNKfuU.png)

![](https://i.imgur.com/k133lJN.png)
![](https://i.imgur.com/jtnuM5y.png)
![](https://i.imgur.com/p9P4ZyQ.png)
![](https://i.imgur.com/5wDx3Zr.png)
### 觀念
![](https://i.imgur.com/ruOxPNR.png)

![](https://i.imgur.com/KhOE1pM.png)
![](https://i.imgur.com/yOpuDFZ.png)

alt+/
![](https://i.imgur.com/fWJOTKE.png)

* ...:代表未來可以放多個字串
一緯度字串陣列
![](https://i.imgur.com/bDk9u6y.png)
![](https://i.imgur.com/dIsSaQ4.png)

ctrl+shift+o
![](https://i.imgur.com/FqxoOSg.png)

### DemoLogProviderAction

```clike=
package tw.leonchen.action;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import tw.leonchen.util.LogProvider;

public class DemoLogProviderAction {

	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("beans.config.xml");
		
		LogProvider logProvider1 = (LogProvider)context.getBean("logProvider");
		logProvider1.log("hola, Amigo !!");
		
		LogProvider logProvider2 =  context.getBean("logProvider",LogProvider.class);
		logProvider2.log("adios,Amigo !!");

		((ConfigurableApplicationContext)context).close();
	}

}
```
### IOC控制反轉
![](https://i.imgur.com/3Zn3O5g.png)

### 建資料夾
![](https://i.imgur.com/2mxJ7Q6.png)
