Skip to content

Commit 603954a

Browse files
committed
added codes
1 parent 96c9c73 commit 603954a

File tree

46 files changed

+836
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+836
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Maven ###
2+
/target/
3+
### STS ###
4+
.apt_generated
5+
.classpath
6+
.factorypath
7+
.project
8+
.settings
9+
.springBeans
10+
.sts4-cache
11+
.settings
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/nbbuild/
22+
/dist/
23+
/nbdist/
24+
/.nb-gradle/
25+
/build/
26+
27+
### VS Code ###
28+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<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/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<!--设置本项目的groupId artifactId 和版本信息-->
5+
<groupId>com.xingyun</groupId>
6+
<artifactId>CodeFactoryPatternSample</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<description>直接编码实现工厂模式</description>
9+
10+
<properties>
11+
<!-- 设置项目所使用的编码为UTF-8 -->
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<!--设置项目所用JDK版本,也可以使用低版本,建议使用JDK1.8以上版本-->
14+
<java.version>12</java.version>
15+
<maven.compiler.source>${java.version}</maven.compiler.source>
16+
<maven.compiler.target>${java.version}</maven.compiler.target>
17+
<maven.compiler.plugin.version>3.5.1</maven.compiler.plugin.version>
18+
<!--是否跳过测试-->
19+
<skipTests>true</skipTests>
20+
<!--设置项目使用第三方依赖包,建议以后都采用这种方式,统一在一个地方声明版本号,这样对项目可以统一管理,方便以后升级-->
21+
<lombok.version>1.18.8</lombok.version>
22+
</properties>
23+
24+
<dependencies>
25+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
26+
<dependency>
27+
<groupId>org.projectlombok</groupId>
28+
<artifactId>lombok</artifactId>
29+
<version>${lombok.version}</version>
30+
<scope>provided</scope>
31+
</dependency>
32+
</dependencies>
33+
34+
<build>
35+
<plugins>
36+
<!--该插件限定Maven 打包时所使用的版本,避免出现版本不匹配问题-->
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>${maven.compiler.plugin.version}</version>
41+
<configuration>
42+
<source>${java.version}</source>
43+
<target>${java.version}</target>
44+
</configuration>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.xingyun;
2+
3+
import com.xingyun.factory.UserFactory;
4+
import com.xingyun.interfaces.IUser;
5+
import com.xingyun.model.User;
6+
7+
/**
8+
* @author 星云
9+
* @Description
10+
* @Date 9/5/2019 8:09 AM
11+
*/
12+
public class Test1 {
13+
14+
public static void main(String[] args) {
15+
// TODO Auto-generated method stub
16+
IUser iUser = UserFactory.getIUserImpl();
17+
iUser.insertUser(new User());
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.xingyun;
2+
3+
import com.xingyun.factory.UserFactory;
4+
import com.xingyun.interfaces.IUser;
5+
import com.xingyun.model.User;
6+
7+
/**
8+
* @author 星云
9+
* @Description
10+
* @Date 9/5/2019 8:09 AM
11+
*/
12+
public class Test2 {
13+
public static void main(String[] args) {
14+
IUser iUser = UserFactory.getIUserImpl();
15+
iUser.insertUser(new User());
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.xingyun.factory;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.interfaces.impl.IUserOracleImpl;
5+
6+
/**
7+
* @author 星云
8+
* @Description 用户工厂层
9+
* @Date 9/5/2019 8:09 AM
10+
*/
11+
public class UserFactory {
12+
13+
public static IUser getIUserImpl() {
14+
//return new IUserMySQLImpl();
15+
return new IUserOracleImpl();
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.xingyun.interfaces;
2+
3+
import com.xingyun.model.User;
4+
5+
/**
6+
* @author 星云
7+
* @Description 用户服务接口层
8+
* @Date 9/5/2019 8:09 AM
9+
*/
10+
public interface IUser {
11+
/**
12+
* Insert User Interface
13+
* @param user
14+
*/
15+
void insertUser(User user);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.xingyun.interfaces.impl;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.model.User;
5+
6+
/**
7+
* @author 星云
8+
* @Description 用户服务接口MySql实现层
9+
* @Date 9/5/2019 8:09 AM
10+
*/
11+
public class IUserMySqlImpl implements IUser{
12+
@Override
13+
public void insertUser(User user) {
14+
System.out.println("insert to MySQL success");
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.xingyun.interfaces.impl;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.model.User;
5+
6+
/**
7+
* @author 星云
8+
* @Description 用户服务接口Oracle实现层
9+
* @Date 9/5/2019 8:09 AM
10+
*/
11+
public class IUserOracleImpl implements IUser{
12+
@Override
13+
public void insertUser(User user) {
14+
System.out.println("insert to Oracle success");
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.xingyun.model;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import lombok.ToString;
6+
7+
/**
8+
* 用户实体类
9+
* @author 星云
10+
* @Description
11+
* @Date 9/5/2019 8:09 AM
12+
*/
13+
@Getter
14+
@Setter
15+
@ToString
16+
public class User {
17+
/**
18+
* 用户账号
19+
*/
20+
private String username;
21+
/**
22+
* 用户密码
23+
*/
24+
private String password;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Maven ###
2+
/target/
3+
### STS ###
4+
.apt_generated
5+
.classpath
6+
.factorypath
7+
.project
8+
.settings
9+
.springBeans
10+
.sts4-cache
11+
.settings
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/nbbuild/
22+
/dist/
23+
/nbdist/
24+
/.nb-gradle/
25+
/build/
26+
27+
### VS Code ###
28+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<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/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.xingyun</groupId>
4+
<artifactId>NoFactoryPatternSample</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<description>无工厂模式演示案例源码</description>
7+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.xingyun;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.interfaces.impl.IUserMySQLImpl;
5+
import com.xingyun.interfaces.impl.IUserOracleImpl;
6+
import com.xingyun.model.User;
7+
8+
public class Test1 {
9+
10+
public static void main(String[] args) {
11+
// TODO Auto-generated method stub
12+
IUser iUser = new IUserMySQLImpl();
13+
//IUser iUser = new IUserOracleImpl();
14+
iUser.insert(new User());
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.xingyun;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.interfaces.impl.IUserOracleImpl;
5+
import com.xingyun.model.User;
6+
7+
public class Test2 {
8+
public static void main(String[] args) {
9+
//IUser iUser = new IUserMySQLImpl();
10+
IUser iUser = new IUserOracleImpl();
11+
iUser.insert(new User());
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.xingyun.interfaces;
2+
3+
import com.xingyun.model.User;
4+
5+
/***
6+
* Óû§½Ó¿Ú
7+
* ****/
8+
public interface IUser {
9+
public void insert(User user);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.xingyun.interfaces.impl;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.model.User;
5+
6+
public class IUserMySQLImpl implements IUser{
7+
8+
public void insert(User user) {
9+
// TODO Auto-generated method stub
10+
System.out.println("insert to MySQL success");
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.xingyun.interfaces.impl;
2+
3+
import com.xingyun.interfaces.IUser;
4+
import com.xingyun.model.User;
5+
6+
public class IUserOracleImpl implements IUser{
7+
8+
public void insert(User user) {
9+
// TODO Auto-generated method stub
10+
System.out.println("insert to Oracle success");
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.xingyun.model;
2+
3+
public class User {
4+
public String username;
5+
public String password;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Maven ###
2+
/target/
3+
### STS ###
4+
.apt_generated
5+
.classpath
6+
.factorypath
7+
.project
8+
.settings
9+
.springBeans
10+
.sts4-cache
11+
.settings
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/nbbuild/
22+
/dist/
23+
/nbdist/
24+
/.nb-gradle/
25+
/build/
26+
27+
### VS Code ###
28+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.xingyun</groupId>
6+
<artifactId>SpringBeanFactoryPatternSample</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<description>Spring Bean工厂 案例源码</description>
9+
10+
<dependencies>
11+
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
12+
<dependency>
13+
<groupId>commons-logging</groupId>
14+
<artifactId>commons-logging</artifactId>
15+
<version>1.2</version>
16+
</dependency>
17+
18+
<!-- Spring 核心Jar包 -->
19+
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
20+
<dependency>
21+
<groupId>org.springframework</groupId>
22+
<artifactId>spring-core</artifactId>
23+
<version>5.1.2.RELEASE</version>
24+
</dependency>
25+
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
26+
<dependency>
27+
<groupId>org.springframework</groupId>
28+
<artifactId>spring-context</artifactId>
29+
<version>5.1.2.RELEASE</version>
30+
</dependency>
31+
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
32+
<dependency>
33+
<groupId>org.springframework</groupId>
34+
<artifactId>spring-beans</artifactId>
35+
<version>5.1.2.RELEASE</version>
36+
</dependency>
37+
</dependencies>
38+
</project>

0 commit comments

Comments
 (0)