If you start the front-end and back-end separation versions according to the project

According to the start of the project

1. Download the source code

git clone https://gitee.com/y_project/RuoYi-Vue.git

After pulling the code and decompressing it

Project structure:

image-20230118103726802

2. Project dependencies

1. Front-end dependencies

image-20230118104133352

2. Backend dependencies

Modularity:

image-20230118103920967

rely:

image-20230118104007336

3. Project configuration

1. Front-end configuration

View the package.json file, you can see the basic dependencies and configuration, and the project structure can be ignored first

npm install    安装依赖

2. Backend configuration

pom.xml file download dependency

yaml file to modify

Redis configuration modification

redis.host  改成自己的ip

mysql configuration modification

1、url   
2、username
3、password   

4. Start

Frontend starts:

npm run dev 

backend start

Find the ruoyi-admin module, find RuoYiApplication and click start

5. Encountered problems

1. The front-end login verification code picture is not displayed

My situation is: I deleted the ruoyi configuration in yaml, and the verification code cannot be displayed

Found through debug, under CaptchaController

 @GetMapping("/captchaImage")
    public AjaxResult getCode(HttpServletResponse response) throws IOException
    {
    
    
        AjaxResult ajax = AjaxResult.success();
        boolean captchaEnabled = configService.selectCaptchaEnabled();
        ajax.put("captchaEnabled", captchaEnabled);
        if (!captchaEnabled)
        {
    
    
            return ajax;
        }

        // 保存验证码信息
        String uuid = IdUtils.simpleUUID();
        String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;

        String capStr = null, code = null;
        BufferedImage image = null;

        // 生成验证码
        //这里 会加载  yaml中的文件 获取math的验证码生产方式 我把yaml中注释了 这里报空
        String captchaType = RuoYiConfig.getCaptchaType();
        
        if ("math".equals(captchaType))
        {
    
    
            String capText = captchaProducerMath.createText();
            capStr = capText.substring(0, capText.lastIndexOf("@"));
            code = capText.substring(capText.lastIndexOf("@") + 1);
            image = captchaProducerMath.createImage(capStr);
        }
        else if ("char".equals(captchaType))
        {
    
    
            capStr = code = captchaProducer.createText();
            image = captchaProducer.createImage(capStr);
        }

        redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
        // 转换流信息写出
        FastByteArrayOutputStream os = new FastByteArrayOutputStream();
        try
        {
    
    
            ImageIO.write(image, "jpg", os);
        }
        catch (IOException e)
        {
    
    
            return AjaxResult.error(e.getMessage());
        }

        ajax.put("uuid", uuid);
        ajax.put("img", Base64.encode(os.toByteArray()));
        return ajax;
    }

2. Login failed

The login uses spring-security, and the login can be successful

Find the SysLoginController class under system, find

    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody)
    {
    
    
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                loginBody.getUuid());
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }

View the details of the loginService.login(xxx) method

    AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));  这行代码老是报错  注释掉就可以 

After some research, I just let go of the internationalization comments in the yaml configuration file

# Spring配置
spring:
#   资源信息
  messages:
    # 国际化资源文件路径
    basename: i18n/messages

3. Summary:

​ Yaml cannot be deleted casually. My mistake is to delete the configuration. You must have the ability to solve problems. Through debugging, you can read the code of the framework and sort out the project process

Guess you like

Origin blog.csdn.net/hekai7217/article/details/128724785