# Spring 2/23 從0開始建立專案 ###### tags: `Spring` [老師云端](https://1drv.ms/u/s!Ans47I9-PkivwFaYGiqWCMQTAylZ) # JDK11(建議用)   ### 環境變數   ### cmd         ### 編碼  ### 字體  ### 總編碼  ### a-z .ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz  ### maven   ### maven   ### 變數  ### cmd  ### 開啟檔案    <localRepository>C:\DataSource\maven_repository\repository</localRepository>  maven_repository  repository ### 複製   ### mavne     ### 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 (重新整理)    alt+f5 ### tomcat      [他母貓](http://localhost:8080/) ### tomcat   ###    [hibernate](https://hibernate.org/orm/releases/)     * 都下一步 然後完成 不要調皮亂按 中間過程都按同意  ###    sql.jdbc   jdbc:sqlserver://localhost:8080;databaseName=LeonPower watcher P@ssw0rd xml  ```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> ``` ### 懶人用法  ### sql  watcher P@ssw0rd   勾那個就能得到全部 xml ->1433  [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> ```  ### 備份   ### Spring [Spring](https://github.com/spring-projects/toolsuite-distribution/wiki/Spring-Tool-Suite-3) 4->3   ###    ### [Index of release/org/springframework/spring/5.3.4](https://repo.spring.io/release/org/springframework/spring/5.3.4/)  ### pom.xml  ```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檔(另一種方式可不做)        ### 組態檔      選沒有版本的規格 end 如果沒改道  ### class  ### beans.config.xml組態檔       ### 觀念    alt+/  * ...:代表未來可以放多個字串 一緯度字串陣列   ctrl+shift+o  ### 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控制反轉  ### 建資料夾 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up