Jeecg-Boot初始化项目

Jeecg-Boot初始化项目

一、软件版本

  • jeecg-boot版本:2.1.1

官方论坛: http://www.jeecg.org/
一键启动或重启:https://blog.csdn.net/u011424614/article/details/105479159

二、具体记录

1.重命名

1)修改项目的文件夹名称,例如:

  • jeecg-boot 改为 example-boot
  • ant-design-vue-jeecg 改为 ant-design-vue-example

2) IntelliJ IDEA 导入后端项目

  • 修改 .idea 包中的 .name 文件,将 jeecg-boot-parent 改为 example-boot

  • 父 pom.xml 的 <artifactId>jeecg-boot-parent</artifactId> 改为 <artifactId>example-boot</artifactId>

  • 两个子模块 pom.xml 中,parent 节点,将 <artifactId>jeecg-boot-parent</artifactId> 改为 <artifactId>example-boot</artifactId>

  • 修改项目根目录的 jeecg-boot-parent.iml 的文件名为 example-boot.iml

  • 重启 IntelliJ IDEA 或者 打开另外一个项目,就可以 File -> Open Recent 直观的切换项目了

2.请求链接

修改后端的请求链接,从 /jeecg-boot 改为 /example-boot

1)后端:

  • 修改配置文件: application-dev.ymlapplication-test.ymlapplication-prod.yml
server:
    # ......
    servlet:
       context-path: /example-boot
    # ......

2)前端

  • 修改 public/index.html
<!-- ...... -->
  <!-- 全局配置 -->
  <script>
    <!-- ...... -->
    window._CONFIG['domianURL'] = 'http://127.0.0.1:8080/example-boot';
    <!-- ...... -->
  </script>
<!-- ...... -->
  • 修改 vue.config.js
// ......
  devServer: {
    // ......
    proxy: {
    // ......
      '/example-boot': {
        // ......
      },
    }
  },
  • 修改 src/utils/request.js
// ......
// 创建 axios 实例
const service = axios.create({
  baseURL: '/example-boot', // api base_url
  // ......
})
// ......
  • 修改依赖包的文件 node_modules\@jeecg\antd-online\dist\OnlineForm.umd.min.js

GIthub Issues:https://github.com/zhangdaiscott/jeecg-boot/issues/467

// ......
var Ne=c.a.create({baseURL:"/example-boot",timeout:15e3})
// ......

3.子模块

官方说明: http://doc.jeecg.com/1273938

  • 目前的架构容易依赖混乱,不适宜新增子模块
  • 建议使用子包管理业务代码,例如:在 jeecg-boot-module-system 模块中,新增业务包 org.jeecg.modules.exambiz

为什么依赖混乱?

  • maven 的依赖传递性

怎么解决?

  • 需要将权限管理模块和demo模块抽离为单独子模块(个人想法,并未实践)

4.自定义业务包

  • 例如:在 jeecg-boot-module-system 模块中,新增 src.main.java.com.example 包(域名倒写作为包名,与 src.main.java.org.jeecg 同级)
  • 因为需要解决 spring 扫描注入的问题,所以需要手动指定扫描的包目录

具体操作如下:

  • 修改 org.jeecg.JeecgApplication.java ,新增扫描注解
// ......
@ComponentScan(basePackages = {"org.jeecg.*", "com.example.*"})
public class JeecgApplication {
    // ......
}
  • 修改 org.jeecg.config.MybatisPlusConfig.java ,修改扫描注解
// ......
@MapperScan(value={"org.jeecg.modules.**.mapper*", "com.example.**.mapper*"})
public class MybatisPlusConfig {
    // ......
}
  • 修改 org.jeecg.modules.system.aspect.DictAspect.java ,修改切点注解
// .....
// 定义切点Pointcut
@Pointcut("execution(public * org.jeecg.modules..*.*Controller.*(..))"
        +"||execution(public * com.example.modules..*.*Controller.*(..))")
public void excudeService() {
}
// .....
  • 修改 application-dev.ymlapplication-test.ymlapplication-prod.yml
# ......
#mybatis plus 设置
mybatis-plus:
  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:com/example/modules/**/xml/*Mapper.xml
# ......

5.LomBok插件

官方工具安装说明: http://doc.jeecg.com/1273968

解决 get/set 方法不存在的问题

  • IntelliJ IDEA - File - Setting - Plugins : 搜索 lombok ,点击 install

三、其它

1.前端修改的文件

更换名称和 logo 等信息

  • Login.vue
  • UserLayout.vue
  • UserMenu.vue
  • Logo.vue
  • GlobalHeader.vue
  • GlobalFooter.vue
  • Analysis.vue
  • public/index.html

2.解决VUE页面的403错误

vue页面中请求第三方资源时报 403 错误;

比如请求第三方网站的文件或图片等,出现 403 错误。

  • public\index.html 中新增下方的元信息
<head>
    <!-- ...... -->
    <meta data-n-head="ssr" name="referrer" content="no-referrer">
    <!-- ...... -->
</head>
<!-- ...... -->

3.打包本地jar包

  • 场景说明:jeecg-boot-module-system 模块的 resource 中添加 lib 文件夹;最终打包时,将 lib 文件夹下的 jar 打包到项目中

  • 本地包导入

<!-- ...... -->		
<dependency>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0.3</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/test-1.0.3.jar</systemPath>
</dependency>
<!-- ...... -->
  • 打包配置:spring-boot-maven-plugin 插件中添加配置
<!-- ...... -->		
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>
<!-- ...... -->
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

趴着喝可乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值