diff --git a/example-main/pom.xml b/example-main/pom.xml index 2cde56df81d60f54e6b8dc181fdf6ea84cf4a77a..510a03223c38b26e41bcfa548e345c7edb4cbc66 100644 --- a/example-main/pom.xml +++ b/example-main/pom.xml @@ -74,6 +74,11 @@ ${knife4j.version} + + org.springframework.boot + spring-boot-starter-quartz + + com.baomidou diff --git a/example-main/src/main/resources/mapper/AutowiredType.xml b/example-main/src/main/resources/mapper/AutowiredTypeDefiner.xml similarity index 100% rename from example-main/src/main/resources/mapper/AutowiredType.xml rename to example-main/src/main/resources/mapper/AutowiredTypeDefiner.xml diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/Basic1Plugin.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/Basic1Plugin.java index 86e313b703a79e0f360ffd6e7a7aa51f1020077a..9709ee2a2831272c6eedb2ef7e729e51f34e7582 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/Basic1Plugin.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/Basic1Plugin.java @@ -3,6 +3,7 @@ package com.gitee.starblues.example.basic1; import com.gitee.starblues.bootstrap.SpringPluginBootstrap; import com.gitee.starblues.bootstrap.annotation.DisablePluginWeb; import com.gitee.starblues.bootstrap.annotation.OneselfConfig; +import com.gitee.starblues.bootstrap.realize.AutowiredTypeDefiner; import com.gitee.starblues.example.Application; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration; @@ -17,10 +18,10 @@ import java.net.URL; * @since 2021-08-01 */ @SpringBootApplication +@OneselfConfig(mainConfigFileName = {"application.yml", "application-dev.yml"}) public class Basic1Plugin extends SpringPluginBootstrap { public static void main(String[] args) { new Basic1Plugin().run(Application.class, args); } - } diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/CallerController.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/CallerController.java index df9a8b0edbbcc932b2a502bfd521ef5fd311d708..5a62dbb6ac8969fc6f05c519b41b9e5ca3bd8132 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/CallerController.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/CallerController.java @@ -1,5 +1,6 @@ package com.gitee.starblues.example.basic1.rest; +import com.gitee.starblues.bootstrap.annotation.AutowiredType; import com.gitee.starblues.example.basic1.config.BasicConfig; import com.gitee.starblues.example.basic1.service.ServiceCaller; import io.swagger.annotations.Api; @@ -29,6 +30,7 @@ public class CallerController { private ServiceCaller serviceCaller; @Autowired + @AutowiredType(value = AutowiredType.Type.MAIN) private DataSource dataSource; @GetMapping("/test") diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/MainUserController.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/MainUserController.java index 9ebc02a951a9efccd97b4da64ad83c8b7fa46a68..cea0d4738050e425f3700b722ba1f95131f7b673 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/MainUserController.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/MainUserController.java @@ -1,5 +1,6 @@ package com.gitee.starblues.example.basic1.rest; +import com.gitee.starblues.bootstrap.annotation.AutowiredType; import com.gitee.starblues.example.entity.MainUser; import com.gitee.starblues.example.service.MainUserService; import io.swagger.annotations.Api; @@ -21,6 +22,7 @@ import java.util.List; public class MainUserController { @Autowired + @AutowiredType(value = AutowiredType.Type.MAIN) private MainUserService mainUserService; diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/BasicService.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/BasicService.java index 55690435ce499490db0689ab948df2da0ff8edbc..1e51eb395572b1f486abc0124cafae58cb7edcc2 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/BasicService.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/BasicService.java @@ -21,7 +21,7 @@ public class BasicService { private PluginDescriptor pluginDescriptor; @Autowired - @AutowiredType(AutowiredType.Type.PLUGIN_MAIN) + @AutowiredType(value = AutowiredType.Type.MAIN) private MainUserService mainUserService; public String getName(){ diff --git a/example-plugins-db/example-jpa/pom.xml b/example-plugins-db/example-jpa/pom.xml index 7bb05090c6169c7960184f1d45143f77f680cde3..211433fdb977b2f4d4c5ca9825457ae25d8371ec 100644 --- a/example-plugins-db/example-jpa/pom.xml +++ b/example-plugins-db/example-jpa/pom.xml @@ -18,12 +18,12 @@ org.springframework.boot spring-boot-starter-quartz - 2.5.0 + ${spring-boot.version} org.springframework.boot spring-boot-starter-data-jpa - 2.5.0 + ${spring-boot.version} diff --git a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/config/Config.java b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/config/Config.java index 72d94dbbed7b2ffd430c368bdb9080724625a9d0..b267f4a08ba0903868daa225a10e65c4e84c633e 100644 --- a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/config/Config.java +++ b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/config/Config.java @@ -1,6 +1,7 @@ package com.gitee.starblues.example.mp.config; -import com.gitee.starblues.bootstrap.realize.MainEnvironmentProvider; +import com.gitee.starblues.bootstrap.PluginContextHolder; +import com.gitee.starblues.spring.environment.EnvironmentProvider; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import org.springframework.context.annotation.Bean; @@ -14,7 +15,8 @@ import org.springframework.context.annotation.Configuration; public class Config { @Bean - public HikariDataSource dataSource(MainEnvironmentProvider environmentProvider){ + public HikariDataSource dataSource(){ + EnvironmentProvider environmentProvider = PluginContextHolder.getEnvironmentProvider(); // 从主程序获取配置 String url = environmentProvider.getString("spring.datasource.url"); String username = environmentProvider.getString("spring.datasource.username"); diff --git a/example-plugins-db/example-mybatis-plus/src/main/resources/mapper/AutowiredType.xml b/example-plugins-db/example-mybatis-plus/src/main/resources/mapper/MpPluginUserMapper.xml similarity index 100% rename from example-plugins-db/example-mybatis-plus/src/main/resources/mapper/AutowiredType.xml rename to example-plugins-db/example-mybatis-plus/src/main/resources/mapper/MpPluginUserMapper.xml