JeecgBoot新增一个module

1、目的

将新增的业务代码和jeecgboot的原框架代码,尽可能解耦,方便后面的升级,也减少因修改框架源码,造成框架性错误;

2、步骤

1、新建一个maven项目, 作为业务module,在这里我的module为yuanqu-module

<?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-boot-parent</artifactId>
        <groupId>org.jeecgframework.boot</groupId>
        <version>3.1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.sanyitu.yuanqu</groupId>
    <artifactId>yuanqu-module</artifactId>

    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.jeecgframework.boot</groupId>
            <artifactId>jeecg-boot-base-core</artifactId>
        </dependency>
        <!--引入微服务启动依赖 starter
      <dependency>
          <groupId>org.jeecgframework.boot</groupId>
          <artifactId>jeecg-boot-starter-cloud</artifactId>
      </dependency>
        <dependency>
            <groupId>org.jeecgframework.boot</groupId>
            <artifactId>jeecg-boot-starter-job</artifactId>
        </dependency>-->
    </dependencies>
</project>

2、父级模块中要包含本次新建的模块

3、启动模块jeecg-boot-module-system ,增加对yuanqu-module的依赖

 4、为了使用swagger接口文档,swagger扫描包要修改成自己的

  //.apis(RequestHandlerSelectors.basePackage("org.jeecg"))
                .apis(RequestHandlerSelectors.basePackage("com.sanyitu"))

 5、新建测试接口

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@Api(tags="新建-园区")
@RestController
@RequestMapping("/hello")
public class HelloController {
    @ApiOperation(value="hello", notes="hello")
    @GetMapping(value="/")
    public Result<String> hello(){
        Result<String> result = new Result<String>();
        result.setResult("hello word!");
        result.setSuccess(true);
        return result;
    }
}

6、接口文档校验新接口

7、yaml配置文件,配置扫描Mapper.xml文件的路径

 

#mybatis plus 设置
mybatis-plus:
  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:com/sanyitu/yuanqu/**/xml/*Mapper.xml

8、MybatisPlusSaasConfig文件,配置扫描mapper文件

@MapperScan(value={"org.jeecg.modules.**.mapper*","com.sanyitu.yuanqu.**.mapper*"})

 7,8主要解决的问题,无法加载新生成的代码

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
JeecgBoot一个基于SpringBoot的快速开发平台,它提供了许多常用的功能例如代码生成、权限管理、数据字典、日志管理等等。而Vue2是一种流行的JavaScript框架,它可以用来构建现代化的Web应用程序。在JeecgBoot中使用Vue2可以帮助我们更快速地开发现代化的Web应用程序。 下面是使用JeecgBoot和Vue2开发Web应用程序的基本步骤: 1. 创建一个JeecgBoot项目,可以使用JeecgBoot的代码生成器来创建一个基础的项目。 2. 在JeecgBoot项目中集成Vue2,可以使用npm包管理器来安装Vue2。在项目的根目录下执行以下命令: ``` npm install vue ``` 3. 创建Vue2组件,可以在JeecgBoot项目的前端资源目录下创建一个新的Vue2组件。例如,在src/main/resources/webapp/vue/components目录下创建一个名为HelloWorld.vue的文件,内容如下: ``` <template> <div> <h1>Hello {{ name }}!</h1> </div> </template> <script> export default { data() { return { name: 'World' } } } </script> ``` 4. 在JeecgBoot项目中使用Vue2组件,可以在JeecgBoot的JSP页面中使用Vue2组件。例如,在src/main/resources/templates目录下创建一个名为index.jsp的文件,内容如下: ``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JeecgBoot Vue2 Demo</title> <script src="/static/js/vue.min.js"></script> </head> <body> <div id="app"> <hello-world></hello-world> </div> <script src="/static/js/app.js"></script> </body> </html> ``` 注意,在页面中引入Vue2的JavaScript文件,以及Vue2组件的JavaScript文件。 5. 编译Vue2组件,可以使用Webpack来编译Vue2组件。在项目的根目录下执行以下命令: ``` npm install webpack webpack-cli vue-loader vue-template-compiler css-loader style-loader --save-dev ``` 然后在项目的根目录下创建一个名为webpack.config.js的文件,内容如下: ``` const path = require('path'); const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { mode: 'development', entry: './src/main/resources/webapp/vue/index.js', output: { path: path.resolve(__dirname, 'src/main/resources/static/js'), filename: 'app.js' }, module: { rules: [ { test: /\.vue$/, loader: 'vue-loader' }, { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] } ] }, plugins: [ new VueLoaderPlugin() ] }; ``` 然后在项目的src/main/resources/webapp/vue目录下创建一个名为index.js的文件,内容如下: ``` import Vue from 'vue'; import HelloWorld from './components/HelloWorld.vue'; new Vue({ el: '#app', components: { 'hello-world': HelloWorld } }); ``` 6. 编译Vue2组件,可以在项目的根目录下执行以下命令: ``` ./node_modules/.bin/webpack --config webpack.config.js ``` 这将会编译Vue2组件,并将编译结果输出到src/main/resources/static/js目录下。 7. 运行JeecgBoot应用程序,可以使用以下命令来启动JeecgBoot应用程序: ``` mvn spring-boot:run ``` 访问http://localhost:8080即可看到Vue2组件在JeecgBoot应用程序中的效果。 这就是使用JeecgBoot和Vue2开发Web应用程序的基本步骤。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值