Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .gitattributes

This file was deleted.

26 changes: 0 additions & 26 deletions .gitignore

This file was deleted.

201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Spring Boot 教学案例

# spring-boot-samples
Spring Boot 教学案例
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.2.121:3310/myshop_0?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
jdbc-url: jdbc:mysql://129.211.60.191:3306/myshop_0?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
username: root
password: '123456'
hikari:
Expand All @@ -27,7 +27,7 @@ spring:
ds1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.2.121:3311/myshop_1?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
jdbc-url: jdbc:mysql://129.211.60.191:3306/myshop_1?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
username: root
password: '123456'
hikari:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class ShardingSphereTests {
@Test
public void testInsertOrder() {
TbOrder tbOrder = new TbOrder();
tbOrder.setOrderId(1L);
tbOrder.setUserId(1L);
tbOrder.setOrderId(3L);
tbOrder.setUserId(2L);

tbOrderMapper.insert(tbOrder);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.funtl.spring.boot;
package com.funtl.spring.hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@MapperScan(basePackages = "com.funtl.spring.boot.mapper")
@MapperScan(basePackages = "com.funtl.spring.hello.mapper")
public class SpringBootDemoApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.funtl.spring.boot.controller;
package com.funtl.spring.hello.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.funtl.spring.boot.domain;
package com.funtl.spring.hello.domain;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.funtl.spring.boot.mapper;
package com.funtl.spring.hello.mapper;

import com.funtl.spring.boot.domain.TbUser;
import com.funtl.spring.hello.domain.TbUser;
import tk.mybatis.mapper.MyMapper;

public interface TbUserMapper extends MyMapper<TbUser> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.funtl.spring.hello.moudule.Prototype;

/**
* @PackgeName: com.funtl.spring.hello.moudule.Prototype
* @ClassName: CloneTest
* @Author: Administrator
* Date: 2020/1/1 0001 17:16
* project name: spring-boot-alibaba-samples
* @Version:
* @Description: 浅度克隆对象的测试
*/
public class CloneTest {
/**
* 原型模式就是从一个对象再创建另外一个可定制的对象, 而且不需要知道任何创建的细节。
* 所谓原型模式, 就是 Java 中的克隆技术, 以某个对象为原型。 复制出新的对象。 显然新的对象具备原型对象的特点, 效率高(避免了重新执行构造过程步骤)
* @param args
*/
public static void main(String[] args) {
Prototype p = new Prototype();
p.name="kang";
p.cloneableTarget = new CloneableTarget("clone","CloneableTarget");
System.out.println("原有的对象:"+p);
System.out.println("原有的值对象引用:"+p.name.hashCode());
System.out.println("原有的引用类型对象:"+p.cloneableTarget);
try {
//方式一 :通过重写clone()方法进行浅拷贝
Prototype clonePrototype = (Prototype) p.clone();
System.out.println("重写clone()克隆的对象:"+clonePrototype);
System.out.println("重写clone()克隆的值对象引用:"+p.name.hashCode());
System.out.println("重写clone()克隆的引用类型对象:"+ clonePrototype.cloneableTarget);

//通过修改引用对象String类型的值,发现原有的对象的值没有发生改变,因为String对象是不可变对象,放在常量池中的,无法修改的
//String 可以比较特殊,可以看做是值传递
clonePrototype.name ="sun";
System.out.println("原有对象的name:"+p.name);
System.out.println("修改过的clone对象的name:"+clonePrototype.name);

//方式二: 通过拷贝构造方法实现浅拷贝
Prototype constructClone= new Prototype(p);
System.out.println("构造方法克隆的对象:"+constructClone);
System.out.println("构造方法克隆的值对象引用:"+constructClone.name.hashCode());
System.out.println("构造方法克隆的引用类型对象:"+ constructClone.cloneableTarget);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.funtl.spring.hello.moudule.Prototype;

/**
* @PackgeName: com.funtl.spring.hello.moudule.Prototype
* @ClassName: CloneableTarget
* @Author: Administrator
* Date: 2020/1/1 0001 17:15
* project name: spring-boot-alibaba-samples
* @Version:
* @Description: 浅度克隆目标的引用对象
*/
public class CloneableTarget {
public String cloneName;

public String cloneClass;

public CloneableTarget( String cloneName,String cloneClass) {
this.cloneName = cloneName;
this.cloneClass = cloneClass;
}
}
Loading