开源若依系统网上资料也很全的,本篇博文记录下自己搭建环境过程中遇到的一些问题。
配置Maven和编辑器选择
我懒得配置Eclipse了,直接用vscode作为编辑器,后面构建运行都用命令行。
配置数据库连接
按照mysql5.7按网上教程即可:win11 下载安装MYSQL 5.7.30(保姆教程)_win11安装mysql5.7-CSDN博客
编辑工程中数据库地址账号:
ruoyi-admin\src\main\resources\application-druid.yml
如图三个红圈:ry_vue是要用mysql或其他数据库编辑工具创建的数据库名字,供当前工程使用。
后面两个是mysql的root账户和密码。
注意密码必须加",否则后面构建会出错
数据库创建和导入数据
我是用脚本建库:
C:\Users\xxx>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 251
Server version: 5.7.30-log MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database ry_vue;
然后使用sql命令导入sql文件:
mysql -u root -p ry_vue < file1.sql
导入数据出现编码错误不支持中文,执行下面语句设置utf编码:
ALTER DATABASE ry_vue CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
接下来,有的sql文件能导入成功,有的会报错。
按照下面方法,可以轻松解决:
mysql> use ry_vue;然后拷贝sql文件里的语句粘贴到这里
启动后台
先构建
mvn clean install
会生成jar包。
然后执行jar包
java -jar target/ruoyi-x.x.x.jar
遇到错误,找不到springboot3,但在ruoyi-admin\pom.xml里有配置如下:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.1.0</version> <configuration><failOnMissingWebXml>false</failOnMissingWebXml><warName>${project.artifactId}</warName></configuration> </plugin>
说明jar找不到pom.xml里的插件。
参考:maven打包可执行jar的pom配置---笔记_打包方式设置为pom-CSDN博客
在pom.xml里增加下面插件:
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>3.1.0</version> <configuration><archive><manifest><mainClass>com.ruoyi.RuoYiApplication</mainClass><addClasspath>true</addClasspath><useUniqueVersions>false</useUniqueVersions><classpathPrefix>lib/</classpathPrefix></manifest><manifestEntries><Class-Path>.</Class-Path></manifestEntries></archive></configuration></plugin>
重新mvn clean install后,再执行jar,能找到springboot3
然后报redis错误。
参考:Redis下载及安装(windows版) - 简书
安装挺简单的。相关命令:
安装服务:
.\redis-server --service-install redis.windows.conf
卸载服务:
redis-server --service-uninstall
开启服务:
redis-server --service-start
停止服务:
redis-server --service-stop
执行jar报还会上报redis要设置密码。
RedisCommandExecutionException: ERR Client sent AUTH, but no password is set
再配置下密码,重启服务即可。
启动前台
只要配置好node,简单,没有问题
cd ruoyi-uinpm install --registry=https://registry.npm.taobao.orgnpm run dev
打开浏览器,输入:http://localhost:80,用账号密码登录
界面看上去比较舒服。