基于SpringBoot 的CMS系统,拿去开发企业官网真香(附源码)

时间: 2023-07-21 00:09:16 浏览次数:121

前言推荐这个项目是因为使用手册部署手册非常完善,项目也有开发教程视频对小白非常贴心,接私活可以直接拿去二开非常舒服

开源说明

系统100%开源模块化开发模式,铭飞所开发的模块都发布到了maven中央库。可以通过pom.xml文件的方式拉取源代码<dependency> <groupId>net.mingsoft</groupId> <artifactId>模块</artifactId> <version>版本号</version> <classifier>sources</classifier> <scope>provided</scope> </dependency>

商用

基于MIT开源协议,可直接商用无需授权,但请尊重开源精神不要去掉代码中铭飞的注释和版权信息

特点

免费完整开源:基于MIT协议,源代码完全开源,无商业限制,MS开发团队承诺将MCMS内容系统永久完整开源;关注Java项目分享标签化建站:不需要专业的后台开发技能,只要使用系统提供的标签,就能轻松建设网站;html静态化:系统支持全站静态化;跨终端:站点同时支持PC与移动端访问,同时会自动根据访问的终端切换到对应的界面,数据由系统统一管理;海量模版:铭飞通过MStore(MS商城)分享更多免费、精美的企业网站模版,降低建站成本;关注Java项目分享丰富插件:为了让MCms适应更多的业务场景,在MStore用户可以下载对应的插件,如:站群插件、微信插件、商城插件等;每月更新:铭飞团队承诺每月28日为系统升级日,分享更多好用等模版与插件;文档丰富:为了让用户更快速的使用MCms系统进行开发,铭飞团队持续更新开发相关文档,如标签文档、使用文档、视频教程等;

面向对象

企 业:帮助创立初期的公司或团队快速搭建产品的技术平台,加快公司项目开发进度;开发者:帮助开发者快速完成承接外包的项目,避免从零搭建系统;学习者:初学JAVA的同学可以下载源代码来进行学习交流;

开发环境

建议开发者使用以下环境,这样避免版本带来的问题

Windows、LinuxEclipse、IdeaMysql≧5.7JDK≧8Tomcat≧8

1. MCms内容插件手册

MCms内容插件提供最基本的菜单、权限、角色、栏目、内容、静态化、等常用功能。视频教程:内容插件视频教程 配合代码生成器使用快速提升开发效率:代码生成器在线视频教程、代码生成器使用文档

1.1. Apache Maven依赖

1.1.1. 当前版本

<!-- ms-mcms 内容模块插件 --> <dependency> <groupId>net.mingsoft</groupId> <artifactId>ms-mcms</artifactId> <version>当前版本</version> </dependency> <!-- ms-mcms 内容模块源码 --> <dependency> <groupId>net.mingsoft</groupId> <artifactId>ms-mcms</artifactId> <version>当前版本</version> <classifier>sources</classifier> </dependency>Copy

1.2. 接口

项目访问路径/swagger-ui.html#/

系统部署手册

1. jar部署

1.1. 打包方式1

懒人做法,将所有的资源打成一个jar包,维护资源不方便,不推荐

mvn clean package java -jar ms-mcms.jarCopy

1.2. 打包方式2(推荐)

打包指令增加参数 -f bin-xml ,执行完成会在target目录会生成 “ 项目-bin ” 发布文件夹

mvn clean package -f bin-xml Copy

1.2.1. 目录结构

config:配置文件

html:静态化自动生成的目录(自动生成)

static:静态资源文件

templets:(必须)模版目录,需要复制一份

upload:(必须)上传的文件夹

WEB-INF:ftl视图文件

mcms.log:自动生成的日志文件

*.sh:linux启动、停止脚本

*.bat:window启动、停止脚本

技术选型

后端框架

技术

名称

官网

Spring Framework

容器

http://projects.spring.io/spring-framework

Spring Boot

MVC框架

https://spring.io/projects/spring-boot

Apache Shiro

安全框架

http://shiro.apache.org

Spring session

分布式Session管理

http://projects.spring.io/spring-session

MyBatis

ORM框架

http://www.mybatis.org

Freemarker

视图框架

http://freemarker.foofun.cn

PageHelper

MyBatis分页插件

http://git.oschina.net/free/Mybatis_PageHelper

Log4J

日志组件

http://logging.apache.org

Maven

项目构建

http://maven.apache.org

Elasticsearch

分布式搜索引擎

https://www.elastic.co

Redis

分布式缓存数据库

https://redis.io

hutool

工具类

http://hutool.mydoc.io

前端框架

技术

名称

官网

vue

函式库

https://cn.vuejs.org//

element ui

UI库

https://element.eleme.cn/2.0/#/zh-CN

jQuery

函式库

http://jquery.com/

Bootstrap

前端框架

http://getbootstrap.com/

Bootstrap-table

Bootstrap数据表格

http://bootstrap-table.wenzhixin.net.cn/

BootstrapValidator

表单验证

http://bootstrapvalidator.com/

Font-awesome

字体图标

http://fontawesome.io/

Waves

点击效果插件

https://github.com/fians/Waves/

zTree

树插件

http://www.treejs.cn/v3/

Select2

选择框插件

https://github.com/select2/select2

Vue

MVVM框架

https://cn.vuejs.org/

AmazeUI

移动端UI

http://amazeui.org/

Plupload

上传控件

http://www.plupload.com/

freemarker

模板引擎

http://freemarker.foofun.cn/toc.html

validator

验证库

https://github.com/chriso/validator.js

animate

动画

http://daneden.github.io/animate.css/

icon

矢量小图标(待更新)

http://ms.mingsoft.net/html/86//6048/index.html

软件截图

铭飞平台

做开源我们是业余的,写代码我们是认真的。研发产品的路上我们一直在探索、一直在学习、一直在用心投入,希望能给更多的企业与开发者提供一些更有价值的服务。

项目管理

代码生成器

源码资料获取方式:关注小编+转发文章+私信【 666 】免费获取八股文面试资料获取方式:关注小编+转发文章+私信【 13 】免费获取重要的事情说三遍,转发+转发+转发,一定要记得点赞转发哦!!!面试官:Spring 和 Spring Boot 的区别是什么?

概述

对于 SpringSpringBoot到底有什么区别,我听到了很多答案,刚开始迈入学习 SpringBoot的我当时也是一头雾水,随着经验的积累、我慢慢理解了这两个框架到底有什么区别,相信对于用了 SpringBoot很久的同学来说,还不是很理解 SpringBoot到底和 Spring有什么区别,看完文章中的比较,或许你有了不同的答案和看法!

什么是Spring

作为 Java开发人员,大家都 Spring都不陌生,简而言之, Spring框架为开发 Java应用程序提供了全面的基础架构支持。它包含一些很好的功能,如依赖注入和开箱即用的模块,如:

SpringJDBC、SpringMVC、SpringSecurity、SpringAOP、SpringORM、SpringTest,这些模块缩短应用程序的开发时间,提高了应用开发的效率例如,在 JavaWeb开发的早期阶段,我们需要编写大量的代码来将记录插入到数据库中。但是通过使用 SpringJDBC模块的 JDBCTemplate,我们可以将操作简化为几行代码。

什么是Spring Boot

SpringBoot基本上是 Spring框架的扩展,它消除了设置 Spring应用程序所需的 XML配置,为更快,更高效的开发生态系统铺平了道路。

SpringBoot中的一些特征:

1、创建独立的 Spring应用。2、嵌入式 TomcatJettyUndertow容器(无需部署war文件)。3、提供的 starters 简化构建配置4、尽可能自动配置 spring应用。5、提供生产指标,例如指标、健壮检查和外部化配置6、完全没有代码生成和 XML配置要求

从配置分析

Maven依赖

首先,让我们看一下使用Spring创建Web应用程序所需的最小依赖项

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.1.0.RELEASE</version> </dependency>

与Spring不同,Spring Boot只需要一个依赖项来启动和运行Web应用程序:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.0.6.RELEASE</version> </dependency>

在进行构建期间,所有其他依赖项将自动添加到项目中。

另一个很好的例子就是测试库。我们通常使用 SpringTestJUnitHamcrestMockito库。在 Spring项目中,我们应该将所有这些库添加为依赖项。但是在 SpringBoot中,我们只需要添加 spring-boot-starter-test依赖项来自动包含这些库。

Spring Boot为不同的Spring模块提供了许多依赖项。一些最常用的是:

spring-boot-starter-data-jpaspring-boot-starter-securityspring-boot-starter-testspring-boot-starter-webspring-boot-starter-thymeleaf

有关 starter的完整列表,请查看Spring文档。

MVC配置

让我们来看一下 SpringSpringBoot创建 JSPWeb应用程序所需的配置。

Spring需要定义调度程序 servlet,映射和其他支持配置。我们可以使用 web.xml 文件或 Initializer类来完成此操作:

public class MyWebAppInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext container) { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setConfigLocation("com.pingfangushi"); container.addListener(new ContextLoaderListener(context)); ServletRegistration.Dynamic dispatcher = container .addServlet("dispatcher", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); } }

还需要将 @EnableWebMvc注释添加到 @Configuration类,并定义一个视图解析器来解析从控制器返回的视图:

@EnableWebMvc @Configuration public class ClientWebConfig implements WebMvcConfigurer { @Bean public ViewResolver viewResolver() { InternalResourceViewResolver bean = new InternalResourceViewResolver(); bean.setViewClass(JstlView.class); bean.setPrefix("/WEB-INF/view/"); bean.setSuffix(".jsp"); return bean; } }

再来看 SpringBoot一旦我们添加了 Web启动程序, SpringBoot只需要在 application配置文件中配置几个属性来完成如上操作:

spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp

上面的所有Spring配置都是通过一个名为auto-configuration的过程添加 Bootweb starter来自动包含的。

这意味着 SpringBoot将查看应用程序中存在的依赖项,属性和 bean,并根据这些依赖项,对属性和 bean进行配置。当然,如果我们想要添加自己的自定义配置,那么 SpringBoot自动配置将会退回。

配置模板引擎

现在我们来看下如何在Spring和Spring Boot中配置Thymeleaf模板引擎。

Spring中,我们需要为视图解析器添加 thymeleaf-spring5依赖项和一些配置:

@Configuration @EnableWebMvc public class MvcWebConfig implements WebMvcConfigurer { @Autowired private ApplicationContext applicationContext; @Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setApplicationContext(applicationContext); templateResolver.setPrefix("/WEB-INF/views/"); templateResolver.setSuffix(".html"); return templateResolver; } @Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.setTemplateResolver(templateResolver()); templateEngine.setEnableSpringELCompiler(true); return templateEngine; } @Override public void configureViewResolvers(ViewResolverRegistry registry) { ThymeleafViewResolver resolver = new ThymeleafViewResolver(); resolver.setTemplateEngine(templateEngine()); registry.viewResolver(resolver); } }

SpringBoot1X只需要 spring-boot-starter-thymeleaf的依赖项来启用 Web应用程序中的 Thymeleaf支持。   但是由于 Thymeleaf3.0中的新功能,我们必须将 thymeleaf-layout-dialect 添加为 SpringBoot2XWeb应用程序中的依赖项。配置好依赖,我们就可以将模板添加到 src/main/resources/templates文件夹中, SpringBoot将自动显示它们。

Spring Security 配置

为简单起见,我们使用框架默认的 HTTPBasic身份验证。让我们首先看一下使用 Spring启用 Security所需的依赖关系和配置。

Spring首先需要依赖 spring-security-webspring-security-config 模块。接下来, 我们需要添加一个扩展 WebSecurityConfigurerAdapter的类,并使用 @EnableWebSecurity注解:

@Configuration @EnableWebSecurity public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("admin") .password(passwordEncoder() .encode("password")) .authorities("ROLE_ADMIN"); } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest().authenticated() .and() .httpBasic(); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } }

这里我们使用 inMemoryAuthentication来设置身份验证。同样, SpringBoot也需要这些依赖项才能使其工作。但是我们只需要定义 spring-boot-starter-security的依赖关系,因为这会自动将所有相关的依赖项添加到类路径中。

SpringBoot中的安全配置与上面的相同

应用程序启动引导配置

SpringSpringBoot中应用程序引导的基本区别在于 servletSpring使用 web.xmlSpringServletContainerInitializer作为其引导入口点。SpringBoot仅使用 Servlet3功能来引导应用程序,下面让我们详细来了解下

Spring 引导配置

Spring支持传统的 web.xml引导方式以及最新的 Servlet3+方法。

配置 web.xml方法启动的步骤

Servlet容器(服务器)读取 web.xml

web.xml中定义的 DispatcherServlet由容器实例化

DispatcherServlet通过读取 WEB-INF/{servletName}-servlet.xml来创建 WebApplicationContext。最后, DispatcherServlet注册在应用程序上下文中定义的 bean

使用 Servlet3+方法的 Spring启动步骤

容器搜索实现 ServletContainerInitializer的类并执行 SpringServletContainerInitializer找到实现所有类 WebApplicationInitializer``WebApplicationInitializer创建具有XML或上下文 @ConfigurationWebApplicationInitializer创建 DispatcherServlet与先前创建的上下文。

SpringBoot 引导配置

Spring Boot应用程序的入口点是使用@SpringBootApplication注释的类

@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }

默认情况下, SpringBoot使用嵌入式容器来运行应用程序。在这种情况下, SpringBoot使用 publicstaticvoidmain入口点来启动嵌入式 Web服务器。此外,它还负责将 ServletFilterServletContextInitializerbean从应用程序上下文绑定到嵌入式 servlet容器。SpringBoot的另一个特性是它会自动扫描同一个包中的所有类或 Main类的子包中的组件。

SpringBoot提供了将其部署到外部容器的方式。我们只需要扩展 SpringBootServletInitializer即可:

/** * War部署 * * @author SanLi * Created by 2689170096@qq.com on 2018/4/15 */ public class ServletInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } @Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext.addListener(new HttpSessionEventPublisher()); } }

这里外部 servlet容器查找在war包下的 META-INF文件夹下MANIFEST.MF文件中定义的 Main-classSpringBootServletInitializer将负责绑定 ServletFilterServletContextInitializer

打包和部署

最后,让我们看看如何打包和部署应用程序。这两个框架都支持 MavenGradle等通用包管理技术。但是在部署方面,这些框架差异很大。例如,Spring Boot Maven插件在 Maven中提供 SpringBoot支持。它还允许打包可执行 jarwar包并 就地运行应用程序。

在部署环境中 SpringBoot 对比 Spring的一些优点包括:

1、提供嵌入式容器支持2、使用命令java -jar独立运行jar3、在外部容器中部署时,可以选择排除依赖关系以避免潜在的jar冲突4、部署时灵活指定配置文件的选项5、用于集成测试的随机端口生成

结论

简而言之,我们可以说 SpringBoot只是 Spring本身的扩展,使开发,测试和部署更加方便。

  非常感谢您读完蓝港网络的这篇文章:"基于SpringBoot 的CMS系统,拿去开发企业官网真香(附源码)",仅为提供更多信息供用户参考使用或为学习交流的方便。我们公司提供:网站建设、网站制作、官网建设、SEO优化、小程序制作等服务,欢迎联系我们提供您的需求。

标签:

Copyright © 常州蓝港网络科技有限公司 苏ICP备2022017479号-1