背景
Jeecg-boot是一个后台管理系统,其提供能很多基础的功能,我希望在不修改jeecg-boot代码的前提下增加自己的功能。经过几天的折腾终于搞定了。
首先是基于jeecg-boot微服务的方式来扩展的,jeecg-boot微服务本身的搭建过程就不讲了,主要讲增加的功能如何与jeecg-boot集成在一起。先说步骤:
1.依赖
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>3.7.0</version>
</parent>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<!-- 加载了上面几个 jeecg-boot核心的就有了,包括授权之类的。 其他按需加载 -->
2.配置
@Slf4j
@EnableFeignClients
@SpringBootApplication
@MapperScan(value={
"com.snail.**.mapper*","org.jeecg.**.mapper*"}) // mybatis集成
@ComponentScan(value= {
"com.snail","org.jeecg"},excludeFilters = {
@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes = {
Swagger2Config.class})}) // 重写Swagger2Config
public class SnailDemoApplication extends SpringBootServletInitializer implements CommandLineRunner {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SnailDemoApplication.class);
}
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext application = SpringApplication.run(SnailDemoApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = StrUtil.blankToDefault(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 + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t"