mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-03 20:35:29 +08:00
JeecgBoot 2.4 微服务正式版本发布,基于SpringBoot的低代码平台
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>jeecg-cloud-module</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>2.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jeecg-cloud-system-start</artifactId>
|
||||
<description>jeecg-cloud-system-start基础启动模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 引入jeecg-boot-module-system依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-module-system</artifactId>
|
||||
</dependency>
|
||||
<!-- 引入jeecg-boot-starter-cloud依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-cloud</artifactId>
|
||||
<!--system模块需要排除jeecg-system-cloud-api-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-system-cloud-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--xxl-job定时任务-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-job</artifactId>
|
||||
</dependency>
|
||||
<!--rabbitmq消息队列
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-rabbitmq</artifactId>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,57 @@
|
||||
package org.jeecg;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.tomcat.util.scan.StandardJarScanner;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients(basePackages = {"org.jeecg"})
|
||||
public class JeecgSystemApplication extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(JeecgSystemApplication.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/doc.html\n" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* tomcat-embed-jasper引用后提示jar找不到的问题
|
||||
*/
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory tomcatFactory() {
|
||||
return new TomcatServletWebServerFactory() {
|
||||
@Override
|
||||
protected void postProcessContext(Context context) {
|
||||
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package org.jeecg.modules.cloud.feign.controller;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient;
|
||||
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient2;
|
||||
import org.jeecg.starter.cloud.feign.impl.JeecgFeignService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sys/test")
|
||||
@Api(tags = "feign测试")
|
||||
public class JeecgTestFeignTest {
|
||||
|
||||
@Autowired
|
||||
private JeecgFeignService jeecgFeignService;
|
||||
|
||||
@Autowired
|
||||
private JeecgTestClient jeecgTestClient;
|
||||
|
||||
|
||||
@GetMapping("getMessage")
|
||||
@ApiOperation(value = "测试feign", notes = "测试feign")
|
||||
public Result<String> getMessage() {
|
||||
return jeecgTestClient.getMessage("jeecg-boot");
|
||||
}
|
||||
|
||||
@GetMapping("getMessage2")
|
||||
@ApiOperation(value = "测试动态feign", notes = "测试动态feign")
|
||||
public Result<String> getMessage2() {
|
||||
JeecgTestClient2 jeecgTestClient = jeecgFeignService.newInstance(JeecgTestClient2.class, "jeecg-demo");
|
||||
return jeecgTestClient.getMessage("jeecg-boot2");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.cloud.feign.feign;
|
||||
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author qinfeng
|
||||
*/
|
||||
@Component
|
||||
public class DemoFallback implements FallbackFactory<JeecgTestClient> {
|
||||
|
||||
@Override
|
||||
public JeecgTestClient create(Throwable throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.cloud.feign.feign;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 常规feign接口定义
|
||||
*/
|
||||
@FeignClient(value = "jeecg-demo", fallbackFactory = DemoFallback.class)
|
||||
@Component
|
||||
public interface JeecgTestClient {
|
||||
|
||||
@GetMapping(value = "/test/getMessage")
|
||||
Result<String> getMessage(@RequestParam("name") String name);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.cloud.feign.feign;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 动态feign接口定义
|
||||
*/
|
||||
public interface JeecgTestClient2 {
|
||||
|
||||
@GetMapping(value = "/test/getMessage")
|
||||
Result<String> getMessage(@RequestParam("name") String name);
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
//package org.jeecg.modules.cloud.rabbitmq;
|
||||
//
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
|
||||
//import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
|
||||
//import org.jeecg.common.annotation.RabbitComponent;
|
||||
//import org.jeecg.common.base.BaseMap;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.amqp.support.AmqpHeaders;
|
||||
//import org.springframework.messaging.handler.annotation.Header;
|
||||
//
|
||||
//@RabbitListener(queues = "jeecg_place_order")
|
||||
//@RabbitComponent(value = "helloReceiver1")
|
||||
//public class HelloReceiver1 extends BaseRabbiMqHandler<BaseMap> {
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
|
||||
// super.onMessage(baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
|
||||
// @Override
|
||||
// public void handler(BaseMap map, Channel channel) {
|
||||
// //业务处理
|
||||
// String orderId = map.get("orderId").toString();
|
||||
// System.out.println("Receiver1 : " + orderId);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,29 @@
|
||||
//package org.jeecg.modules.cloud.rabbitmq;
|
||||
//
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
|
||||
//import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
|
||||
//import org.jeecg.common.annotation.RabbitComponent;
|
||||
//import org.jeecg.common.base.BaseMap;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.amqp.support.AmqpHeaders;
|
||||
//import org.springframework.messaging.handler.annotation.Header;
|
||||
//
|
||||
//@RabbitListener(queues = "jeecg_place_order")
|
||||
//@RabbitComponent(value = "helloReceiver2")
|
||||
//public class HelloReceiver2 extends BaseRabbiMqHandler<BaseMap> {
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
|
||||
// super.onMessage(baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
|
||||
// @Override
|
||||
// public void handler(BaseMap map, Channel channel) {
|
||||
// //业务处理
|
||||
// String orderId = map.get("orderId").toString();
|
||||
// System.out.println("Receiver2 : " + orderId);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,29 @@
|
||||
//package org.jeecg.modules.cloud.rabbitmq;
|
||||
//
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
|
||||
//import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
|
||||
//import org.jeecg.common.annotation.RabbitComponent;
|
||||
//import org.jeecg.common.base.BaseMap;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.amqp.support.AmqpHeaders;
|
||||
//import org.springframework.messaging.handler.annotation.Header;
|
||||
//
|
||||
//@RabbitListener(queues = "jeecg_place_order_time")
|
||||
//@RabbitComponent(value = "helloTimeReceiver")
|
||||
//public class HelloTimeReceiver extends BaseRabbiMqHandler<BaseMap> {
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
|
||||
// super.onMessage(baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
|
||||
// @Override
|
||||
// public void handler(BaseMap map, Channel channel) {
|
||||
// //业务处理
|
||||
// String orderId = map.get("orderId").toString();
|
||||
// System.out.println("Receiver1 : " + orderId);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,57 @@
|
||||
|
||||
package org.jeecg.modules.cloud.xxljob;;
|
||||
|
||||
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.xxl.job.core.log.XxlJobLogger;
|
||||
import com.xxl.job.core.util.ShardingUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* xxl-job定时任务测试
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class Demo2JobHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 简单任务
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
|
||||
@XxlJob(value = "demoJob2")
|
||||
public ReturnT<String> demoJobHandler(String params) {
|
||||
log.info("我是定时任务,我执行了...............................");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2、分片广播任务
|
||||
*/
|
||||
|
||||
@XxlJob("shardingJobHandler3")
|
||||
public ReturnT<String> shardingJobHandler(String param) throws Exception {
|
||||
|
||||
// 分片参数
|
||||
ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
|
||||
XxlJobLogger.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardingVO.getIndex(), shardingVO.getTotal());
|
||||
|
||||
// 业务逻辑
|
||||
for (int i = 0; i < shardingVO.getTotal(); i++) {
|
||||
if (i == shardingVO.getIndex()) {
|
||||
XxlJobLogger.log("第 {} 片, 命中分片开始处理", i);
|
||||
} else {
|
||||
XxlJobLogger.log("第 {} 片, 忽略", i);
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
server:
|
||||
#微服务端口
|
||||
port: 7001
|
||||
spring:
|
||||
application:
|
||||
name: jeecg-system
|
||||
Reference in New Issue
Block a user