diff --git a/example-main/pom.xml b/example-main/pom.xml index 510a03223c38b26e41bcfa548e345c7edb4cbc66..a58939370d842b80e0b3b2b1dfd1cf7eeecd393c 100644 --- a/example-main/pom.xml +++ b/example-main/pom.xml @@ -42,11 +42,24 @@ ${spring-brick.version} + + com.gitee.starblues + spring-brick-bootstrap + ${spring-brick.version} + + + + org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-data-jpa + + mysql mysql-connector-java diff --git a/example-main/src/main/java/com/gitee/starblues/example/Application.java b/example-main/src/main/java/com/gitee/starblues/example/Application.java index 47d27e998ea1d7d8c940259c99f7a7eb2897d4f4..aec515d0be8796a33adb9a59f1398c90e016d536 100644 --- a/example-main/src/main/java/com/gitee/starblues/example/Application.java +++ b/example-main/src/main/java/com/gitee/starblues/example/Application.java @@ -1,5 +1,6 @@ package com.gitee.starblues.example; +import com.gitee.starblues.loader.DevelopmentMode; import com.gitee.starblues.loader.launcher.SpringMainBootstrap; import com.gitee.starblues.loader.launcher.SpringBootstrap; import org.mybatis.spring.annotation.MapperScan; @@ -22,4 +23,9 @@ public class Application implements SpringBootstrap { public void run(String[] args) { SpringApplication.run(Application.class, args); } + + @Override + public String developmentMode() { + return DevelopmentMode.COEXIST; + } } diff --git a/example-main/src/main/java/com/gitee/starblues/example/rest/HelloController.java b/example-main/src/main/java/com/gitee/starblues/example/rest/HelloController.java index 5175f6212b392304078af816554f661d0daa6020..cf1c62ebb75a8603eb0dd946ef3a1c2b57ce5013 100644 --- a/example-main/src/main/java/com/gitee/starblues/example/rest/HelloController.java +++ b/example-main/src/main/java/com/gitee/starblues/example/rest/HelloController.java @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController; * @author starBlues * @version 1.0 */ -@RestController +@RestController("mainHello") @RequestMapping("/main/hello") @Api(tags = "main-hello") public class HelloController { diff --git a/example-main/src/main/resources/application-dev.yml b/example-main/src/main/resources/application-dev.yml index af2aa5e63440a27fa2b86ce98752ed7d912d732e..6393ca4ab041832178ac52b236cd54071bbcc769 100644 --- a/example-main/src/main/resources/application-dev.yml +++ b/example-main/src/main/resources/application-dev.yml @@ -27,7 +27,7 @@ plugin: # 如果配置是 windows 下路径, mac、linux 自行修改 pluginPath: - ~\example-plugins-basic - #- ~\example-plugins-db + - ~\example-plugins-db #- ~\example-plugins-cloud sortInitPluginIds: - example-basic-2 @@ -38,4 +38,4 @@ plugin: plugins: - pluginId: example-basic-1 props: - secretKey: mmfvXes1XckCi8F/y9i0uQ== + secretKey: mmfvXes1XckCi8F/y9i0uQ== \ No newline at end of file diff --git a/example-main/src/main/resources/application-prod.yml b/example-main/src/main/resources/application-prod.yml index 4781f15fa2721e3cdda4b27b13c831ee5f537e72..73653a7a0471f3c41a7b523382f16cccc2e0f05e 100644 --- a/example-main/src/main/resources/application-prod.yml +++ b/example-main/src/main/resources/application-prod.yml @@ -23,7 +23,7 @@ mybatis-plus: plugin: runMode: prod mainPackage: com.gitee.starblues.example - pluginPath: ~\plugins + pluginPath: D:\etc\kitte\ksm\springboot-plugin-framework-parent\springboot-plugin-framework-example\dist\plugins sortInitPluginIds: - example-basic-2 - example-basic-1 diff --git a/example-main/src/main/resources/application.yml b/example-main/src/main/resources/application.yml index caf4dfcd647483863672818bd860d4ec4767e8de..90385b2bc7df06e13a08cfd3ffa3b5b4a84ef6c6 100644 --- a/example-main/src/main/resources/application.yml +++ b/example-main/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev \ No newline at end of file + active: prod \ No newline at end of file diff --git a/example-main/src/main/resources/mapper/AutowiredTypeDefiner.xml b/example-main/src/main/resources/mapper/MainUserMapper.xml similarity index 100% rename from example-main/src/main/resources/mapper/AutowiredTypeDefiner.xml rename to example-main/src/main/resources/mapper/MainUserMapper.xml diff --git a/example-plugins-basic/example-basic-1/pom.xml b/example-plugins-basic/example-basic-1/pom.xml index 02b3d8d5ff621eee36faf7c7e5570794f1b482c9..8581773b106f036298ffcbc31cbe2b8209a12ff4 100644 --- a/example-plugins-basic/example-basic-1/pom.xml +++ b/example-plugins-basic/example-basic-1/pom.xml @@ -29,7 +29,7 @@ basic1-config.yaml - jar-outer + jar 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 9709ee2a2831272c6eedb2ef7e729e51f34e7582..8dd5e71ae0849cd9d845316e00038cf79666938c 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 @@ -7,6 +7,7 @@ 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; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.PropertySource; import java.net.URL; @@ -19,6 +20,7 @@ import java.net.URL; */ @SpringBootApplication @OneselfConfig(mainConfigFileName = {"application.yml", "application-dev.yml"}) +@EnableConfigurationProperties public class Basic1Plugin extends SpringPluginBootstrap { public static void main(String[] args) { diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/HelloController.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/HelloController.java index 2d093ae178afb66309e14fd4531f3042a75c47e4..624c7897e55629b4cf4ba4db281518e8509270a2 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/HelloController.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/rest/HelloController.java @@ -7,6 +7,8 @@ import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; @@ -30,6 +32,8 @@ public class HelloController { @GetMapping() public PluginDescriptor hello(){ + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + System.out.println(attributes.getRequest().getRequestURI()); return pluginDescriptor; } 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 1e51eb395572b1f486abc0124cafae58cb7edcc2..ca46be8e33fc1921d78b0167507a2ae54066b033 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 @@ -5,6 +5,7 @@ import com.gitee.starblues.core.descriptor.PluginDescriptor; import com.gitee.starblues.example.service.MainUserService; import com.gitee.starblues.example.service.TestAnnotation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; */ @Service @TestAnnotation +@Scope("prototype") public class BasicService { @Autowired diff --git a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/listener/MyListener.java b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/listener/MyListener.java index e9a9d2edfa0b4ccf9c3e505c0c93ba6a66695b70..ed1e1629666eec4914e4bb91c279355c429b9214 100644 --- a/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/listener/MyListener.java +++ b/example-plugins-basic/example-basic-1/src/main/java/com/gitee/starblues/example/basic1/service/listener/MyListener.java @@ -1,6 +1,7 @@ package com.gitee.starblues.example.basic1.service.listener; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; import org.springframework.boot.context.event.ApplicationPreparedEvent; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -10,16 +11,20 @@ import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextStartedEvent; import org.springframework.context.event.ContextStoppedEvent; +import org.springframework.stereotype.Component; /** * 启动后监听 * @author starBlues * @version 1.0 */ +@Slf4j +@Component public class MyListener implements ApplicationListener{ @Override public void onApplicationEvent(ApplicationEvent event) { + log.info("插件==================================== : {}" , event.getClass().getName()); if (event instanceof ApplicationEnvironmentPreparedEvent) { System.out.println("初始化环境变量"); } else if (event instanceof ApplicationPreparedEvent) { diff --git a/example-plugins-basic/example-basic-2/src/main/java/com/gitee/starblues/example/basic2/Basic2Plugin.java b/example-plugins-basic/example-basic-2/src/main/java/com/gitee/starblues/example/basic2/Basic2Plugin.java index c08b5dc0764257a9c9cbb5c1bd144af05b47aced..bbd816bbf77520475d48f3ef034f3fc64e259636 100644 --- a/example-plugins-basic/example-basic-2/src/main/java/com/gitee/starblues/example/basic2/Basic2Plugin.java +++ b/example-plugins-basic/example-basic-2/src/main/java/com/gitee/starblues/example/basic2/Basic2Plugin.java @@ -1,6 +1,8 @@ package com.gitee.starblues.example.basic2; import com.gitee.starblues.bootstrap.SpringPluginBootstrap; +import com.gitee.starblues.bootstrap.annotation.OneselfConfig; +import com.gitee.starblues.example.Application; import org.springframework.boot.autoconfigure.SpringBootApplication; /** @@ -10,10 +12,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @since 2021-08-01 */ @SpringBootApplication +@OneselfConfig(mainConfigFileName = {"application.yml", "application-dev.yml"}) public class Basic2Plugin extends SpringPluginBootstrap { public static void main(String[] args) { - new Basic2Plugin().run(args); + new Basic2Plugin().run(Application.class, args); } } diff --git a/example-plugins-basic/pom.xml b/example-plugins-basic/pom.xml index 068a1da13294118c1b2f401b0be4991826a4ff90..a197b4748b9eaef5679e72bb90df2ae3405a5e66 100644 --- a/example-plugins-basic/pom.xml +++ b/example-plugins-basic/pom.xml @@ -25,18 +25,6 @@ - - org.springframework.boot - spring-boot-starter - ${spring-boot.version} - - - - com.gitee.starblues - spring-brick-bootstrap - ${spring-brick.version} - - com.gitee.starblues example-main diff --git a/example-plugins-cloud/example-plugin-cloud-nacos/pom.xml b/example-plugins-cloud/example-plugin-cloud-nacos/pom.xml index 5c6cb2c66d375457682aaafc3b28ec1612dad217..369ffee36ffa1b8ebb59e22c7c032fa0b6f757de 100644 --- a/example-plugins-cloud/example-plugin-cloud-nacos/pom.xml +++ b/example-plugins-cloud/example-plugin-cloud-nacos/pom.xml @@ -16,22 +16,6 @@ - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-aop - - - - com.gitee.starblues - spring-brick-bootstrap - - com.gitee.starblues example-main diff --git a/example-plugins-cloud/pom.xml b/example-plugins-cloud/pom.xml index 6cf7a4556be11d7d840145b35a87a742c9c7f30d..3261026f81a1034a6e28bbd4750a9a5a90082247 100644 --- a/example-plugins-cloud/pom.xml +++ b/example-plugins-cloud/pom.xml @@ -27,24 +27,6 @@ - - org.springframework.boot - spring-boot-starter - ${spring-boot.version} - - - - org.springframework.boot - spring-boot-starter-aop - ${spring-boot.version} - - - - com.gitee.starblues - spring-brick-bootstrap - ${spring-brick.version} - - com.gitee.starblues example-main diff --git a/example-plugins-db/example-jpa/pom.xml b/example-plugins-db/example-jpa/pom.xml index 211433fdb977b2f4d4c5ca9825457ae25d8371ec..2bde5d92b529ca75685a85b508c28998f223db65 100644 --- a/example-plugins-db/example-jpa/pom.xml +++ b/example-plugins-db/example-jpa/pom.xml @@ -15,17 +15,6 @@ - - org.springframework.boot - spring-boot-starter-quartz - ${spring-boot.version} - - - org.springframework.boot - spring-boot-starter-data-jpa - ${spring-boot.version} - - javax.xml.bind diff --git a/example-plugins-db/example-jpa/src/main/java/com/gitee/starblues/example/jpa/JpaPlugin.java b/example-plugins-db/example-jpa/src/main/java/com/gitee/starblues/example/jpa/JpaPlugin.java index 2b6b58d5e2cd06b4815fb6cb7cc43bb01971a40c..5f33b17765b249a2ead361d8d3b76847dce2b750 100644 --- a/example-plugins-db/example-jpa/src/main/java/com/gitee/starblues/example/jpa/JpaPlugin.java +++ b/example-plugins-db/example-jpa/src/main/java/com/gitee/starblues/example/jpa/JpaPlugin.java @@ -1,6 +1,7 @@ package com.gitee.starblues.example.jpa; import com.gitee.starblues.bootstrap.SpringPluginBootstrap; +import com.gitee.starblues.bootstrap.coexist.CoexistAllowAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; @@ -16,4 +17,11 @@ public class JpaPlugin extends SpringPluginBootstrap{ new JpaPlugin().run(JpaPlugin.class, args); } + @Override + protected void configCoexistAllowAutoConfiguration(CoexistAllowAutoConfiguration configuration) { + configuration.add("org.springframework.boot.autoconfigure.jdbc"); + configuration.add("org.springframework.boot.autoconfigure.data.jpa"); + configuration.add("org.springframework.boot.autoconfigure.orm.jpa"); + configuration.add("org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration"); + } } diff --git a/example-plugins-db/example-mybatis-plus/pom.xml b/example-plugins-db/example-mybatis-plus/pom.xml index 79fc694e016413b2b2ea1849a429183943610418..3d999117929482b7bdf829ab39551ac87296d499 100644 --- a/example-plugins-db/example-mybatis-plus/pom.xml +++ b/example-plugins-db/example-mybatis-plus/pom.xml @@ -12,15 +12,6 @@ example-mybatis-plus - - - com.baomidou - mybatis-plus-boot-starter - 3.5.0 - - - - diff --git a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/MybatisPlusExamplePlugin.java b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/MybatisPlusExamplePlugin.java index 5df193f89ec7feaefeb11ea683be1b0225b6121f..9cfcc2a48fd2f75dc3235e8cb672a3eb5d8a50de 100644 --- a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/MybatisPlusExamplePlugin.java +++ b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/MybatisPlusExamplePlugin.java @@ -1,6 +1,7 @@ package com.gitee.starblues.example.mp; import com.gitee.starblues.bootstrap.SpringPluginBootstrap; +import com.gitee.starblues.bootstrap.coexist.CoexistAllowAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; /** @@ -13,5 +14,9 @@ public class MybatisPlusExamplePlugin extends SpringPluginBootstrap { public static void main(String[] args) { new MybatisPlusExamplePlugin().run(args); } - + + @Override + protected void configCoexistAllowAutoConfiguration(CoexistAllowAutoConfiguration configuration) { + configuration.add("com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration"); + } } diff --git a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/rest/MpPluginUserController.java b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/rest/MpPluginUserController.java index 08936e38501599f6b885da28760c976febb0f524..4db21caae74723e185aebf57bdaf14c7b203e721 100644 --- a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/rest/MpPluginUserController.java +++ b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/rest/MpPluginUserController.java @@ -7,6 +7,8 @@ import io.swagger.annotations.Api; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * user 接口 @@ -23,12 +25,17 @@ public class MpPluginUserController { private final MpPluginUserService mpPluginUserService; @GetMapping - public Page getPage(@RequestParam("currentPage") Integer currentPage, + public Page getPage(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize){ Page plugin2UserPage = new Page<>(currentPage, pageSize); return mpPluginUserService.page(plugin2UserPage); } + @GetMapping("/wrapper") + public List getPage(){ + return mpPluginUserService.testWrapper(); + } + @GetMapping("/{id}") public MpPluginUser getById(@PathVariable("id") String id){ diff --git a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/MpPluginUserService.java b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/MpPluginUserService.java index f983771392ed21ce7407e4079b8f6b123f160d60..e7ed136f755aa58a25e398ce7145e5e8f02047d9 100644 --- a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/MpPluginUserService.java +++ b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/MpPluginUserService.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.gitee.starblues.example.mp.entity.MpPluginUser; import com.gitee.starblues.example.mp.mapper.MpPluginUserMapper; +import java.util.List; + /** *

* 插件1-用户表 服务类 @@ -14,6 +16,8 @@ import com.gitee.starblues.example.mp.mapper.MpPluginUserMapper; */ public interface MpPluginUserService extends IService { + List testWrapper(); + @Override MpPluginUserMapper getBaseMapper(); } diff --git a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/impl/MpPluginUserServiceImpl.java b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/impl/MpPluginUserServiceImpl.java index 42e1c9818e486ac7ed49e1aeb440892d33c073e3..4b2b918103396ebdde5c3d4d845f5da5481aeeb1 100644 --- a/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/impl/MpPluginUserServiceImpl.java +++ b/example-plugins-db/example-mybatis-plus/src/main/java/com/gitee/starblues/example/mp/service/impl/MpPluginUserServiceImpl.java @@ -1,11 +1,16 @@ package com.gitee.starblues.example.mp.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gitee.starblues.bootstrap.annotation.ResolveClassLoader; import com.gitee.starblues.example.mp.entity.MpPluginUser; import com.gitee.starblues.example.mp.mapper.MpPluginUserMapper; import com.gitee.starblues.example.mp.service.MpPluginUserService; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 插件1-用户表 服务实现类 @@ -17,4 +22,11 @@ import org.springframework.stereotype.Service; @Service public class MpPluginUserServiceImpl extends ServiceImpl implements MpPluginUserService { + @ResolveClassLoader + @Override + public List testWrapper() { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(MpPluginUser.class) + .eq(MpPluginUser::getDeleted, 0); + return list(wrapper); + } } diff --git a/example-plugins-db/pom.xml b/example-plugins-db/pom.xml index 7a858733bb9d7085edf32807a5e3aefb1b060a4d..1e2eebe21d98e454105952d7b80a61b8e61d1f75 100644 --- a/example-plugins-db/pom.xml +++ b/example-plugins-db/pom.xml @@ -25,18 +25,6 @@ - - org.springframework.boot - spring-boot-starter - ${spring-boot.version} - - - - com.gitee.starblues - spring-brick-bootstrap - ${spring-brick.version} - - com.gitee.starblues example-main diff --git a/pom.xml b/pom.xml index 37cb55da96f5a2ae391c39fac621eaba343772ce..0ce493f01ed2e6a339b85a54dbb1e0b95ca7806d 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 1.8 - 3.0.3 + 3.1.0 2.5.6