一、概述
编写目的
这个项目基本把电商的业务和平台都完整的展示出来了,很多项目只是展示一个后台管理,但是,那并不是完整的企业级项目,而这个lilishop却是一个完整的项目,并且进行了开源代码,在这里要对其做出的贡献表示感谢.
由于本系统的文档不够完善,缺少简单的部署流程,使得很多新人,或没有接触这个系统的人,很难简单快捷的实现,快速部署这个系统,同时,能够快速搭建,学习起来的状况,这也是目前国内开源的一大弊病,明明做的项目不差,但是由于文档缺乏,配置繁琐,导致很难快速上手,快速开发,快速学习,快速使用,所以,特此撰写此文章,此文章为原创设计,拒绝抄袭,如有转载,请注明出处.
服务器部署
由于笔者是一个开发人员,所以部署主要以开发的部署到本地的情况为主,文章这是范例,实际的问题,还需要自身学习百度功能,和自身对于一门技术的理解,希望大家努力学习,争取自己领悟部署的方法,本文部署主要选取常用的windows系统作为主要的部署环境,希望大家提高自身的部署能力.
二、基本构建
构建工具(参考文献,其他版本安装流程基本一样)
三、Git 导入编译器
四、模块描述浅析
序号 |
模块名称 |
描述 |
1 |
admin |
监控模块,用于监控整个系统的服务状况 |
2 |
buyer-api |
买家接口模块(就是你在商城想购物,你就是这个买家) |
3 |
common-api |
公共代码模块,list转set什么的一般放这里,自己不要瞎写方法,公共的都放这里 |
4 |
config |
公共配置文档的模块.用于全局配置文件的修改,一般全局修改改这里 |
5 |
consumer |
消费者模块,消费服务,定时任务延时任务 |
6 |
DB |
数据脚本存放位置,本地部署前要跑一下数据库的脚本 |
7 |
framework |
核心代码(重点可以被学习的地方) |
8 |
lilishop-ui |
前段界面代码模块(三方的前台代码都在这里) |
9 |
manager-api |
运营管理模块,就是运营小姐姐给你处理订单异常,售后,退款,这类问题的平台 |
10 |
seller-api |
商家模块(店铺),你买的所有东西都是商家提供的,你看看淘宝每个商品点击可以看到商铺,这里就是商铺模块,供应商提供货源,平台提供销路 |
11 |
xxl-job |
定时任务管理模块,跑一些定时或自动的业务 |
五、配置文档
序号 |
名称 |
位置 |
文件名称 |
1 |
admin |
src/main/resources |
application.yml |
2 |
buyer-api |
src/main/resources |
application.yml |
3 |
common-api |
src/main/resources |
application.yml |
4 |
config |
src/main/resources |
application.yml |
5 |
consumer |
src/main/resources |
application.yml |
6 |
manager-api |
src/main/resources |
application.yml |
7 |
seller-api |
src/main/resources |
application.yml |
- 本文暂时以商城主页的项目为主教程,其他的模块一样,待自行举一反三.
1.注释配置文件
序号 |
名称 |
位置 |
文件名称 |
1 |
buyer-api |
src/main/resources |
application.yml |
2 |
common-api |
src/main/resources |
application.yml |
3 |
config |
src/main/resources |
application.yml |
- 注释以上三个模块的如下代码,这里的代码含义就是忽略这些接口的访问,不注释的话,以下接口无法访问.启动包含swagger的访问.
# 忽略鉴权url
#ignored:
# urls:
# - /editor-app/**
# - /actuator**
# - /actuator/**
# - /MP_verify_qSyvBPhDsPdxvOhC.txt
# - /weixin/**
# - /source/**
# - /buyer/mini-program/**
# - /buyer/cashier/**
# - /buyer/pageData/**
# - /buyer/article/**
# - /buyer/goods/**
# - /buyer/category/**
# - /buyer/shop/**
# - /buyer/connect/**
# - /buyer/members/smsLogin
# - /buyer/members/refresh/*
# - /buyer/members/refresh**
# - /buyer/promotion/pintuan
# - /buyer/promotion/seckill
# - /buyer/memberEvaluation/**/goodsEvaluation
# - /buyer/memberEvaluation/**/evaluationNumber
# - /store/login/**
# - /manager/user/login
# - /manager/user/refresh/**
# - /druid/**
# - /swagger-ui.html
# - /doc.html
# - /swagger-resources/**
# - /swagger/**
# - /webjars/**
# - /v2/api-docs
# - /configuration/ui
# - /boot-admin
# - /**/*.js
# - /**/*.css
# - /**/*.png
# - /**/*.ico
2.添加配置
- 由于本项目采用的是比较新的技术,叫做knife4j,所以配置要偏向于knife4j和swagger的配置,引入包位置
序号 |
名称 |
位置 |
文件名称 |
1 |
framework |
framework/ |
pom.yml |
序号 |
名称 |
位置 |
文件名称 |
1 |
lilishop |
lilishop/ |
pom.yml |
序号 |
名称 |
位置 |
文件名称 |
1 |
buyer-api |
src/main/resources |
application.yml |
2 |
common-api |
src/main/resources |
application.yml |
3 |
config |
src/main/resources |
application.yml |
spring:
mvc:
view:
prefix: /
suffix: .html
freemarker:
check-template-location: false
thymeleaf:
check-template-location: false
3.暂时关闭权限
- 由于除了忽略以外,本项目还开起了security的权限,如果不关闭这个权限,那么还是无法访问项目的swagger.
序号 |
名称 |
位置 |
文件名称 |
1 |
buyer-api |
src/main/java/security |
BuyerAuthenticationFilter BuyerSecurityConfig |
- 由于项目比较复杂,为了达到简单高效的目的,第一步注释代码BuyerAuthenticationFilter,(不注释就算解开了权限,最后,还需要账户密码登陆,暂时没找到这个的登陆账号密码)
- 修改代码BuyerSecurityConfig,使其跟common-api下的权限一致.
package cn.lili.security;
import cn.lili.cache.Cache;
import cn.lili.common.security.CustomAccessDeniedHandler;
import cn.lili.common.utils.SpringContextUtil;
import cn.lili.common.properties.IgnoredUrlsProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.web.cors.CorsConfigurationSource;
/**
* spring Security 核心配置类 Buyer安全配置中心
*
* @author Chopper
* @version v4.0
* @since 2020/11/14 16:20
*/
@Slf4j
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class BuyerSecurityConfig extends WebSecurityConfigurerAdapter {
/**
* 忽略验权配置
*/
@Autowired
private IgnoredUrlsProperties ignoredUrlsProperties;
/**
* spring security -》 权限不足处理
*/
@Autowired
private CustomAccessDeniedHandler accessDeniedHandler;
@Autowired
private Cache<String> cache;
@Autowired
private CorsConfigurationSource corsConfigurationSource;
@Override
protected void configure(HttpSecurity http) throws Exception {
// 注释这里的过滤权限代码
// ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
// .authorizeRequests();
// //配置的url 不需要授权
// for (String url : ignoredUrlsProperties.getUrls()) {
// registry.antMatchers(url).permitAll();
// }
// registry
// .and()
// //禁止网页iframe
// .headers().frameOptions().disable()
// .and()
// .logout()
// .permitAll()
// .and()
// .authorizeRequests()
// //任何请求
// .anyRequest()
// //需要身份认证
// .authenticated()
// .and()
// //允许跨域
// .cors().configurationSource((CorsConfigurationSource) SpringContextUtil.getBean("corsConfigurationSource")).and()
// //关闭跨站请求防护
// .csrf().disable()
// //前后端分离采用JWT 不需要session
// .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
// .and()
// //自定义权限拒绝处理类
// .exceptionHandling().accessDeniedHandler(accessDeniedHandler)
// .and()
// //添加JWT认证过滤器
// .addFilter(new BuyerAuthenticationFilter(authenticationManager(), cache));
// 粘贴这里的不需要权限访问代码
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
.authorizeRequests();
registry
.and()
//禁止网页iframe
.headers().frameOptions().disable()
.and()
.authorizeRequests()
//任何请求
.anyRequest()
//需要身份认证
.permitAll()
.and()
//允许跨域
.cors().configurationSource(corsConfigurationSource).and()
//关闭跨站请求防护
.csrf().disable();
}
}
4.浏览器测试访问
5.其他需要修改模块
- 步骤与上述一样,本博主相信你可以自行修改成功,加油,看好你!
序号 |
名称 |
位置 |
文件名称 |
1 |
admin |
src/main/resources |
application.yml |
2 |
consumer |
src/main/resources |
application.yml |
3 |
manager-api |
src/main/resources |
application.yml |
4 |
seller-api |
src/main/resources |
application.yml |
六、参考文献
knife4j只用此插件的最简洁开发方式
Knife4j添加lombok及注解初探
Knife4j 注解详谈
结语
呕心沥血,爆肝一个星期(需要写配置环境的文档,还要反复测试,以便为各位看官老爷提供最好的精品文章),希望点赞,收藏,评论,转发,您的支持就是本博主前进的动力,后期将推出完整部署文档,未完待续 .....
最新文章
- URL转义
- js == 与 === 的区别,‘’与“”的区别
- >Python下使用subprocess中文乱码的解决方案
- 2.PHP内核探索:一次请求的开始与结束
- [转]bat中的特殊字符,以及需要在bat中当做字符如何处理
- (转)c &; c++内存分配
- java第五课:方法
- Json序列化、反序列化互换
- numpy 札记
- win10 uwp 通知Toast
- JMeter(十三)-代理服务器录制脚本
- SSM框架下声明式事务管理(注解配置方式)
- selenium基础实例学习
- 对于ps基本操作的归纳
- Template 动画
- Ext JS 6学习文档-第3章-基础组件
- gulp压缩css和js
- OpenStack制作Windows 2008 KVM镜像
- MongoDB Wiredtiger存储引擎实现原理——Copy on write的方式管理修改操作,Btree cache
- ROS Learning-002 beginner_Tutorials 如何添加ROS环境变量 和 如何更新ROS源代码
热门文章
- 员工管理系统+字符编码+Python代码文件操作
- JavaScript的原生Ajax解析
- Solution -「CF 1586F」Defender of Childhood Dreams
- IDA FLIRT使用
- Java超全大纲.jpg
- 在shell中变量的赋值有五种方法!
- 微信小程序获取经纬度所在城市
- layout_gravity和gravity
- ibv_get_device_list()函数
- 《手把手教你》系列技巧篇(七十一)-java+ selenium自动化测试-自定义类解决元素同步问题(详解教程)