jeecg-boot新建module模块

本文档介绍了如何在jeecg-boot项目中新建一个module,并将其添加到jeecg-boot-module-system中作为依赖。详细步骤包括创建maven项目,修改pom.xml,创建业务包和代码,配置Swagger2Config以展示接口文档。在Swagger中,通过添加@Api和@ApiOperation注解确保接口在文档中可见,并解决Shiro拦截问题。
摘要由CSDN通过智能技术生成

随着jeecg-boot不断拓展更新,爱好者越来越多,对于刚入门或者刚从事java(springboot)的人来说,会遇到各种各样的问题。

今天就对jeecg-boot开源项目上的一个issues:373,写个手册-jeecg-boot下多模块项目。

从issues:373 ,可以看出提问者,他想新建一个jeecg-boot-module-jm bundle,然后在 jeecg-boot-module-system 中依赖这个模块。

前提条件:jeecg-boot-module-system 能成功编译,并且jeecg-boot-module-system能成功启动

(数据库、redis配置正确)

jeecg-boot新建module模块

新建maven项目

新建maven项目 取名jeecg-boot-module-jm

可以采用idea、myeclipse 等工具来新建一个maven项目

其中 pom.xml文件内容如下

<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">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>jeecg-boot-module-jm</artifactId>
	<version>2.0.2</version>

	<parent>
		<groupId>org.jeecgframework.boot</groupId>
		<artifactId>jeecg-boot-parent</artifactId>
		<version>2.0.2</version>
	</parent>

	<repositories>
		<repository>
			<id>aliyun</id>
			<name>aliyun Repository</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>jeecg</id>
			<name>jeecg Repository</name>
			<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	
	<dependencies>
		<dependency>
			<groupId>org.jeecgframework.boot</groupId>
			<artifactId>jeecg-boot-base-common</artifactId>
		</dependency>
	</dependencies>
	
	<!-- <build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build> -->
</project>

注意:我这个pom文件直接复制了jeecg-boot-module-system 内容,将jeecg-boot-module-system名称改为jeecg-boot-module-jm,注意注释了

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

这段代码,因为新建的项目要打包为jar在jeecg-boot-module-system引用,所以不需要把该项目打包一个springboot项目,注释上面的代码就可以了。

  • 创建业务包

在项目根目录新建包名org.jeecg.modules.hello(以issues:373为例,也可以使用其他包名,记住这个包名,后面在接口问题swagger-ui使用到)

  • 添加业务(测试)代码

(以issues:373为例,后面针对提出的问题,进行一一解答)这段代码后面在swagegr-ui中访问不到,因为方法上没有添加@ApiOperation

package org.jeecg.modules.hello;

import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

impor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值