From fa40e05502f0789f727a8f1e52e43b45f86c0c4d Mon Sep 17 00:00:00 2001 From: huayanYu Date: Thu, 13 Jul 2023 22:18:04 +0800 Subject: [PATCH] up --- .../ds/controller/DataSourceController.java | 2 +- .../samples/load/LoadDsApplication.java | 2 +- features-samples/nest-sample/pom.xml | 50 -------------- .../samples/nest/NestApplication.java | 29 -------- .../nest/controller/TestController.java | 51 -------------- .../baomidou/samples/nest/entiry/Student.java | 28 -------- .../baomidou/samples/nest/entiry/Teacher.java | 28 -------- .../samples/nest/mapper/StudentMapper.java | 32 --------- .../samples/nest/mapper/TeacherMapper.java | 32 --------- .../samples/nest/service/SchoolService.java | 27 -------- .../samples/nest/service/StudentService.java | 30 --------- .../samples/nest/service/TeacherService.java | 33 ---------- .../nest/service/impl/SchoolServiceImpl.java | 57 ---------------- .../nest/service/impl/StudentServiceImpl.java | 50 -------------- .../nest/service/impl/TeacherServiceImpl.java | 59 ----------------- .../src/main/resources/application.yml | 28 -------- .../src/main/resources/db/schema.sql | 15 ----- .../nest/test/NestApplicationTest.java | 66 ------------------- .../baomidou/samples/spel/test/SPELTest.java | 2 +- springboot3-sample/pom.xml | 2 +- .../boot3/service/impl/UserServiceImpl.java | 2 +- .../MyQuartzAutoConfigurationMode2.java | 2 +- .../config/MyDataSourceConfiguration.java | 2 +- .../config/MyDataSourceConfiguration.java | 3 +- 24 files changed, 8 insertions(+), 624 deletions(-) delete mode 100644 features-samples/nest-sample/pom.xml delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/NestApplication.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/controller/TestController.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Student.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Teacher.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/StudentMapper.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/TeacherMapper.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/SchoolService.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/StudentService.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/TeacherService.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/SchoolServiceImpl.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/StudentServiceImpl.java delete mode 100644 features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/TeacherServiceImpl.java delete mode 100644 features-samples/nest-sample/src/main/resources/application.yml delete mode 100644 features-samples/nest-sample/src/main/resources/db/schema.sql delete mode 100644 features-samples/nest-sample/src/test/java/com/baomidou/samples/nest/test/NestApplicationTest.java diff --git a/features-samples/add-remove-datasource-sample/src/main/java/com/baomidou/samples/ds/controller/DataSourceController.java b/features-samples/add-remove-datasource-sample/src/main/java/com/baomidou/samples/ds/controller/DataSourceController.java index 1fa821f..e82289d 100644 --- a/features-samples/add-remove-datasource-sample/src/main/java/com/baomidou/samples/ds/controller/DataSourceController.java +++ b/features-samples/add-remove-datasource-sample/src/main/java/com/baomidou/samples/ds/controller/DataSourceController.java @@ -16,8 +16,8 @@ package com.baomidou.samples.ds.controller; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.common.DataSourceProperty; import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; import com.baomidou.samples.ds.dto.DataSourceDTO; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/features-samples/load-datasource-from-jdbc-sample/src/main/java/com/baomidou/samples/load/LoadDsApplication.java b/features-samples/load-datasource-from-jdbc-sample/src/main/java/com/baomidou/samples/load/LoadDsApplication.java index 89887f8..856f1e9 100644 --- a/features-samples/load-datasource-from-jdbc-sample/src/main/java/com/baomidou/samples/load/LoadDsApplication.java +++ b/features-samples/load-datasource-from-jdbc-sample/src/main/java/com/baomidou/samples/load/LoadDsApplication.java @@ -15,9 +15,9 @@ */ package com.baomidou.samples.load; -import com.baomidou.dynamic.datasource.common.DataSourceProperty; import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider; import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; diff --git a/features-samples/nest-sample/pom.xml b/features-samples/nest-sample/pom.xml deleted file mode 100644 index 4e9119e..0000000 --- a/features-samples/nest-sample/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - features-samples - com.baomidou - 1.0.0 - - 4.0.0 - - nest-sample - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-validation - - - org.springdoc - springdoc-openapi-ui - - - com.baomidou - dynamic-datasource-spring-boot-starter - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - - - com.h2database - h2 - - - org.projectlombok - lombok - provided - - - org.springframework.boot - spring-boot-starter-test - test - - - \ No newline at end of file diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/NestApplication.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/NestApplication.java deleted file mode 100644 index e2a221a..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/NestApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -@MapperScan("com.baomidou.samples.nest.mapper") -public class NestApplication { - - public static void main(String[] args) { - SpringApplication.run(NestApplication.class, args); - } -} \ No newline at end of file diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/controller/TestController.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/controller/TestController.java deleted file mode 100644 index fe5c4bb..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/controller/TestController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.controller; - -import com.baomidou.samples.nest.service.SchoolService; -import com.baomidou.samples.nest.service.StudentService; -import com.baomidou.samples.nest.service.TeacherService; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@AllArgsConstructor -public class TestController { - - private final SchoolService schoolService; - private final TeacherService teacherService; - private final StudentService studentService; - - @GetMapping("/tx1") - public void tx1() { - //外层不加事物,里面每个单独加事物(支持) - schoolService.addTeacherAndStudent(); - } - - @GetMapping("/tx2") - public void tx2() { - //外层加事物,里面每个也加事物(不支持) - schoolService.addTeacherAndStudentWithTx(); - } - - @GetMapping("/tx3") - public void tx3() { - //单独调用加事物单库(支持) - teacherService.addTeacherWithTx("Mr Wang", 30); - studentService.addStudentWithTx("Zhang San", 12); - } -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Student.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Student.java deleted file mode 100644 index e977ec4..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Student.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.entiry; - -import lombok.Data; - -@Data -public class Student { - - private Integer id; - - private String name; - - private Integer age; -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Teacher.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Teacher.java deleted file mode 100644 index a8e41f1..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/entiry/Teacher.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.entiry; - -import lombok.Data; - -@Data -public class Teacher { - - private Integer id; - - private String name; - - private Integer age; -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/StudentMapper.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/StudentMapper.java deleted file mode 100644 index c7fd0d1..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/StudentMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.mapper; - -import com.baomidou.samples.nest.entiry.Student; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -public interface StudentMapper { - - @Insert("insert into student (name,age) values (#{name},#{age})") - boolean addStudent(@Param("name") String name, @Param("age") Integer age); - - @Select("SELECT * FROM student") - List selectStudents(); -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/TeacherMapper.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/TeacherMapper.java deleted file mode 100644 index fb5aa72..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/mapper/TeacherMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.mapper; - -import com.baomidou.samples.nest.entiry.Teacher; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -public interface TeacherMapper { - - @Insert("insert into teacher (name,age) values (#{name},#{age})") - boolean addTeacher(@Param("name") String name, @Param("age") Integer age); - - @Select("SELECT * FROM teacher") - List selectTeachers(); -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/SchoolService.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/SchoolService.java deleted file mode 100644 index bfdebbb..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/SchoolService.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service; - -public interface SchoolService { - - void selectTeachersAndStudents(); - - void selectTeachersInnerStudents(); - - void addTeacherAndStudent(); - - void addTeacherAndStudentWithTx(); -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/StudentService.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/StudentService.java deleted file mode 100644 index 8f0ecba..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/StudentService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service; - -import com.baomidou.samples.nest.entiry.Student; - -import java.util.List; - -public interface StudentService { - - boolean addStudentWithTx(String name, Integer age); - - boolean addStudentNoTx(String name, Integer age); - - - List selectStudents(); -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/TeacherService.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/TeacherService.java deleted file mode 100644 index 8280655..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/TeacherService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service; - -import com.baomidou.samples.nest.entiry.Teacher; - -import java.util.List; - - -public interface TeacherService { - - boolean addTeacherWithTx(String name, Integer age); - - boolean addTeacherNoTx(String name, Integer age); - - - List selectTeachers(); - - void selectTeachersInnerStudents(); -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/SchoolServiceImpl.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/SchoolServiceImpl.java deleted file mode 100644 index e98cba0..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/SchoolServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service.impl; - -import com.baomidou.samples.nest.service.SchoolService; -import com.baomidou.samples.nest.service.StudentService; -import com.baomidou.samples.nest.service.TeacherService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -public class SchoolServiceImpl implements SchoolService { - - @Autowired - private TeacherService teacherService; - - @Autowired - private StudentService studentService; - - @Override - public void selectTeachersAndStudents() { - teacherService.selectTeachers(); - studentService.selectStudents(); - } - - @Override - public void selectTeachersInnerStudents() { - teacherService.selectTeachersInnerStudents(); - } - - @Override - public void addTeacherAndStudent() { - teacherService.addTeacherWithTx("ss", 1); - studentService.addStudentWithTx("tt", 2); - } - - @Override - @Transactional - public void addTeacherAndStudentWithTx() { - teacherService.addTeacherWithTx("ss", 1); - studentService.addStudentNoTx("tt", 2); - } -} diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/StudentServiceImpl.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/StudentServiceImpl.java deleted file mode 100644 index e64c384..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/StudentServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.samples.nest.entiry.Student; -import com.baomidou.samples.nest.mapper.StudentMapper; -import com.baomidou.samples.nest.service.StudentService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Service -@DS("student") -public class StudentServiceImpl implements StudentService { - - @Autowired - private StudentMapper studentMapper; - - @Override - @Transactional - public boolean addStudentWithTx(String name, Integer age) { - return studentMapper.addStudent(name, age); - } - - @Override - public boolean addStudentNoTx(String name, Integer age) { - return studentMapper.addStudent(name, age); - } - - @Override - public List selectStudents() { - return studentMapper.selectStudents(); - } -} \ No newline at end of file diff --git a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/TeacherServiceImpl.java b/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/TeacherServiceImpl.java deleted file mode 100644 index 6afed59..0000000 --- a/features-samples/nest-sample/src/main/java/com/baomidou/samples/nest/service/impl/TeacherServiceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.samples.nest.entiry.Teacher; -import com.baomidou.samples.nest.mapper.TeacherMapper; -import com.baomidou.samples.nest.service.StudentService; -import com.baomidou.samples.nest.service.TeacherService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Service -@DS("teacher") -public class TeacherServiceImpl implements TeacherService { - - @Autowired - private TeacherMapper teacherMapper; - @Autowired - private StudentService studentService; - - @Override - @Transactional - public boolean addTeacherWithTx(String name, Integer age) { - return teacherMapper.addTeacher(name, age); - } - - @Override - public boolean addTeacherNoTx(String name, Integer age) { - return teacherMapper.addTeacher(name, age); - } - - @Override - public List selectTeachers() { - return teacherMapper.selectTeachers(); - } - - @Override - public void selectTeachersInnerStudents() { - teacherMapper.selectTeachers(); - studentService.selectStudents(); - } -} \ No newline at end of file diff --git a/features-samples/nest-sample/src/main/resources/application.yml b/features-samples/nest-sample/src/main/resources/application.yml deleted file mode 100644 index 99da3c6..0000000 --- a/features-samples/nest-sample/src/main/resources/application.yml +++ /dev/null @@ -1,28 +0,0 @@ -spring: - datasource: - dynamic: - datasource: - master: - username: sa - password: "" - url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE - driver-class-name: org.h2.Driver - schema: classpath:db/schema.sql - salve: - username: sa - password: "" - url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE - driver-class-name: org.h2.Driver - teacher: - username: sa - password: "" - url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE - driver-class-name: org.h2.Driver - student: - username: sa - password: "" - url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE - driver-class-name: org.h2.Driver -logging: - level: - com.baomidou: debug \ No newline at end of file diff --git a/features-samples/nest-sample/src/main/resources/db/schema.sql b/features-samples/nest-sample/src/main/resources/db/schema.sql deleted file mode 100644 index 2604f76..0000000 --- a/features-samples/nest-sample/src/main/resources/db/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE IF NOT EXISTS TEACHER -( - id BIGINT(20) NOT NULL AUTO_INCREMENT, - name VARCHAR(30) NULL DEFAULT NULL, - age INT(11) NULL DEFAULT NULL, - PRIMARY KEY (id) -); - -CREATE TABLE IF NOT EXISTS STUDENT -( - id BIGINT(20) NOT NULL AUTO_INCREMENT, - name VARCHAR(30) NULL DEFAULT NULL, - age INT(11) NULL DEFAULT NULL, - PRIMARY KEY (id) -); \ No newline at end of file diff --git a/features-samples/nest-sample/src/test/java/com/baomidou/samples/nest/test/NestApplicationTest.java b/features-samples/nest-sample/src/test/java/com/baomidou/samples/nest/test/NestApplicationTest.java deleted file mode 100644 index f005749..0000000 --- a/features-samples/nest-sample/src/test/java/com/baomidou/samples/nest/test/NestApplicationTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © ${project.inceptionYear} organization baomidou - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.baomidou.samples.nest.test; - - -import com.baomidou.samples.nest.NestApplication; -import com.baomidou.samples.nest.service.SchoolService; -import com.baomidou.samples.nest.service.StudentService; -import com.baomidou.samples.nest.service.TeacherService; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.util.Random; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = NestApplication.class) - -public class NestApplicationTest { - - private final Random random = new Random(); - - @Autowired - private TeacherService teacherService; - @Autowired - private StudentService studentService; - @Autowired - private SchoolService schoolService; - - @Test - public void nest1() { - //直接在controller - teacherService.selectTeachers(); - studentService.selectStudents(); - } - - @Test - public void nest2() { - schoolService.selectTeachersAndStudents(); - } - - @Test - public void nest3() { - schoolService.selectTeachersInnerStudents(); - } - - @Test - public void tx() { - teacherService.selectTeachers(); - } -} \ No newline at end of file diff --git a/features-samples/spel-sample/src/test/java/com/baomidou/samples/spel/test/SPELTest.java b/features-samples/spel-sample/src/test/java/com/baomidou/samples/spel/test/SPELTest.java index 6e3a680..899183c 100644 --- a/features-samples/spel-sample/src/test/java/com/baomidou/samples/spel/test/SPELTest.java +++ b/features-samples/spel-sample/src/test/java/com/baomidou/samples/spel/test/SPELTest.java @@ -16,8 +16,8 @@ package com.baomidou.samples.spel.test; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.common.DataSourceProperty; import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; import com.baomidou.samples.spel.SpelApplication; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/springboot3-sample/pom.xml b/springboot3-sample/pom.xml index f4976b7..47c9228 100644 --- a/springboot3-sample/pom.xml +++ b/springboot3-sample/pom.xml @@ -34,7 +34,7 @@ com.baomidou - dynamic-datasource-spring-boot3-starter + dynamic-datasource-spring-boot-starter org.mybatis.spring.boot diff --git a/springboot3-sample/src/main/java/com/baomidou/sample/boot3/service/impl/UserServiceImpl.java b/springboot3-sample/src/main/java/com/baomidou/sample/boot3/service/impl/UserServiceImpl.java index c2faee4..7e8ae39 100644 --- a/springboot3-sample/src/main/java/com/baomidou/sample/boot3/service/impl/UserServiceImpl.java +++ b/springboot3-sample/src/main/java/com/baomidou/sample/boot3/service/impl/UserServiceImpl.java @@ -36,7 +36,7 @@ public List selectMasterUsers() { return userMapper.selectUsers(); } - @DS("slave") + @DS("#header.ds") @Override public List selectSlaveUsers() { return userMapper.selectUsers(); diff --git a/third-part-samples/quartz-sample/src/main/java/com/baomidou/samples/quartz/config/MyQuartzAutoConfigurationMode2.java b/third-part-samples/quartz-sample/src/main/java/com/baomidou/samples/quartz/config/MyQuartzAutoConfigurationMode2.java index 3cebb00..44abe7f 100644 --- a/third-part-samples/quartz-sample/src/main/java/com/baomidou/samples/quartz/config/MyQuartzAutoConfigurationMode2.java +++ b/third-part-samples/quartz-sample/src/main/java/com/baomidou/samples/quartz/config/MyQuartzAutoConfigurationMode2.java @@ -16,7 +16,7 @@ package com.baomidou.samples.quartz.config; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.common.DynamicDataSourceProperties; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.autoconfigure.quartz.QuartzDataSource; diff --git a/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-4.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v4/spring/config/MyDataSourceConfiguration.java b/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-4.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v4/spring/config/MyDataSourceConfiguration.java index ec1a763..3758df6 100644 --- a/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-4.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v4/spring/config/MyDataSourceConfiguration.java +++ b/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-4.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v4/spring/config/MyDataSourceConfiguration.java @@ -16,9 +16,9 @@ package com.baomidou.samples.shardingsphere.jdbc.v4.spring.config; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.common.DynamicDataSourceProperties; import com.baomidou.dynamic.datasource.provider.AbstractDataSourceProvider; import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; diff --git a/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-5.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v5/spring/config/MyDataSourceConfiguration.java b/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-5.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v5/spring/config/MyDataSourceConfiguration.java index 6237cb7..dc70fb5 100644 --- a/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-5.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v5/spring/config/MyDataSourceConfiguration.java +++ b/third-part-samples/shardingsphere-sample/shardingsphere-jdbc-5.x-spring-sample/src/main/java/com/baomidou/samples/shardingsphere/jdbc/v5/spring/config/MyDataSourceConfiguration.java @@ -16,10 +16,9 @@ package com.baomidou.samples.shardingsphere.jdbc.v5.spring.config; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; -import com.baomidou.dynamic.datasource.common.DynamicDataSourceProperties; import com.baomidou.dynamic.datasource.provider.AbstractDataSourceProvider; import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; -//import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;