293 Star 921 Fork 397

ujcms / ujcms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

UJCMS

Java开源内容管理系统(java cms)。使用SpringBoot、MyBatis、Spring Security、Lucene、FreeMarker、TypeScript、Vue3、ElementPlus等技术开发。

技术上尽量选择主流、先进、简单的架构,方便用户进行二次开发。设计上强调“简单”、“灵活”,避免繁杂的设计和实现,降低系统维护成本和二次开发难度。功能使用上也要求“简单”,避免复杂的使用逻辑。

支持信创适配,支持国产服务器、国产操作系统、国产数据库、国产中间件。

QQ交流群:626599871

微信交流群:加作者微信拉入群

UJCMS交流群

技术及功能亮点

自定义字段可查询:所有的自定义字段都可查询增强了系统的灵活性。

自定义字段可视化设计:自定义字段使用拖拽式的可视化设计,所见即所得。

URL地址SEO优化:栏目和文章的动态地址可以通过系统的全局设置功能进行修改。默认的栏目和文章URL地址前缀为/channel/article,可以根据自己的需要修改,如改为/categories/archives。多站点的情况下,子站点URL地址可为目录形式(www.example.com/abc)或次级域名形式(abc.example.com)。

清理垃圾附件:系统使用时,可能会多传、误传图片等附件;在删除文章后,文章中的图片还保留在系统中,产生大量的未使用的垃圾图片和附件。系统中的附件管理可以查看所有未使用的图片和附件,并可对其进行删除。

附件、模板、索引文件独立部署:系统运行时产生的文件可以和程序分开,部署到独立的目录,方便系统备份、升级和管理。比如上传的图片和附件、前台的模板、索引文件,都可以部署到程序以外的目录。

模板文件和CSS、JS在同一目录:模板文件和CSS、JS分开的目录结构,会给模板制作和部署带来很大的不便性。而将模板文件和CSS、JS放在一起的设计,会方便很多。

MyBatis参数化查询:后台数据通常会需要通过不同字段进行搜索,对每个表都写大量的查询,无疑是一项繁重的工作。MyBatis参数化查询功能通过前台传递查询参数,即可实现任意字段及关联表的查询功能(如:Q_title=abc,Q_user-username=test),无需后台编写代码,大幅减少后端的开发工作量。

主副表拆分:对查询量大的复杂表进行主副表拆分,把常用的查询字段放到主表,不常用的字段放到副表,提升大数据量下的性能表现。

环境要求

  • JDK 8、11。
  • MySQL 5.7(8.0)。
  • Tomcat 8.5、9.0 (Servlet 3.1+)。
  • Maven 3.5 或更高版本。
  • 系统后台兼容的浏览器:Chrome、Firefox、Edge。
  • 前台页面兼容的浏览器取决于模板,使用者可以完全控制模板,理论上可以支持任何浏览器。演示模板支持Chrome、Firefox、Edge。

创建数据库

  1. 创建数据库。数据库名可为ujcms或其它任何名称。
  • MySQL,字符集选utf8mb4(不要选择utf8,该字符集可能导致某些特殊字符出现乱码)。
  • 达梦数据库,字符集选UTF-8(不要使用GB18030,该字符集可能导致某些特殊字符出现乱码)。
  • 人大金仓数据库,字符集选UTF8(不要使用GBK,该字符集可能导致某些特殊字符出现乱码)。
  1. 无需执行SQL文件,程序启动时会自动创建表及初始化数据。以后程序升级同样不需要执行SQL升级脚本,程序启动时会判断当前软件版本及数据库表结构版本,自动进行数据库表结构升级。

MySQL表名大小写问题

如果在Windows环境使用MySQL,且以后需要迁移到Linux环境的MySQL,建议将Windows环境的MySQL配置为表名大小写敏感模式。

因为Linux环境下MySQL的表名是大小写敏感的;而在Windows环境下MySQL表名大小写不敏感,且会自动把大写的表名改为小写的表名。从Windows向Linux迁移数据时,本为大写表名的成为了小写表名,导致程序出错。需要手动把小写表名改回大写表名,费时费力且容易出错。

UJCMS系统的表名都为小写,不管在Window还是Linux下都没有问题,但第三方的类库(如Liquibase、Flowable、Quartz等)创建的表则为大写表名。所以Windows环境下也把MySQL设置成表名大小写敏感,有利以后迁移数据。

可修改MySQL配置文件my.ini

[mysqld]
# Windows下表名也区分大小写,与Linux一致。
lower_case_table_names=2

启动程序

  1. 在Eclipse中导入maven项目。点击Eclipse菜单File - Import,选择Maven - Existing Maven Projects。创建好maven项目后,会开始从maven服务器下载第三方jar包(如spring等),需要一定时间,请耐心等待。(另外:Eclipse中会出现红叉的错误警告,如是JavaScript或HTML报错则无需理会,不影响程序正常运行。这是由于Eclipse校验规则误判所致,可以在Eclipse中设置禁止对js文件进行错误校验。)
  2. 修改数据库连接。打开/src/main/resources/application.yaml文件,根据实际情况修改spring.datasource.urlspring.datasource.usernamespring.datasource.password的值。其中spring.datasource.url中的数据库名要和上一步创建的数据库名一致。
  3. 启动程序。在eclipse中,右键点击项目名,选择Run as - Java Application,选择Application - com.ujcms,然后点击OK。也可在左侧导航中找到com.ujcms.cms.Application类并右键点击,选择Run as - Java Application即可直接运行。
  4. 使用 IntelliJ IDEA 开发的,步骤与 Eclipse 类似。打开工程后,等待Maven下载依赖,修改数据库连接,然后直接点击右上角的绿色三角图标(Run 'Application'),即可直接运行。也可在左侧导航中找到com.ujcms.cms.Application类并右键点击,选择Run 'Application'
  5. 首次运行程序,会自动创建数据库表和初始化数据库,需要一些时间,请耐心等待,只要没有出现报错信息,说明程序还在启动中,不要急于关闭程序。直到出现类似com.ujcms.cms.Application: Started Application in xxx seconds信息,代表程序启动完成。如果程序首次启动,还在创建数据库表时,强行关闭了程序;再次启动程序可能会出现类似LockException: Could not acquire change log lockWaiting for changelog lock....的报错信息;此时只要将数据库databasechangeloglock表中数据清空(注意,不是databasechangelog表),也可删除数据库所有表甚至重建数据库,再次启动程序即可继续创建数据库表和初始化数据,正常启动。
  6. 前台地址:http://localhost:8080/,使用手机访问前台或者使用浏览器模拟手机访问前台,会自适应显示手机端的界面。如遇到前台页面没有样式的情况,则是因为没有部署在Tomcat的根目录。如前台首页地址类似为http://localhost:8080/abc,即代表部署在/abc目录下,没有部署在根目录。解决办法请参考下一章节内容。
  7. 后台地址:http://localhost:8080/cp/,用户名:admin,密码:password。后台前端基于开发,如要修改后台界面,请另外下载ujcms-cp项目。
  8. 默认访问地址是http://localhost:8080/,如需修改域名、端口等内容,可分别到后台配置 - 系统设置配置 - 站点设置中修改。
  9. 如需关闭开源版中的商业版提示及功能,可以修改/src/main/resources/application.yaml文件中的ujcms.ep-display: false配置。

常见错误

如出现flowable-eventregistry-db-changelog.xml::1::flowable: Specified key was too long; max key length is 767 bytes等错误信息,则 MySQL 5.7 需要设置innodb_large_prefix=ON;MySQL 5.6 需要设置innodb_large_prefix=1。从 mysql 5.7.7 开始,innodb_large_prefix的默认值就是ON,因此只要MySQL版本大于5.7.7即可避免这个问题。

部署

  • 使用maven进行打包mvn package -P war。会生成target/ujcms-***.war文件和target/ujcms-***目录。
  • 用目录方式部署的,可以将target/ujcms-***/目录下文件复制到tomcat的webapps/ROOT目录下(请先删除原tomcat/webapps目录下所有文件夹)。复制完成后有类似webapps/ROOT/uploads webapps/ROOT/templates webapps/ROOT/WEB-INF等文件夹。
  • 也可使用war包部署,将ujcms-***.war更名为ROOT.war(注意大小写),复制到tomcat的webapps目录下(请先删除原tomcat/webapps目录下所有文件夹)。复制完成后文件地址为webapps/ROOT.war文件。war部署要使用解压模式,tomcat默认就是使用解压模式,如修改过tomcat配置,请检查tomcat/conf/server.xml配置文件中<Host ... unpackWARs="true" ... >的配置项。
  • 需注意/WEB-INF/classes/application.yaml文件中的数据库地址、用户名、密码相关配置是否与部署环境的数据库一致。

jar部署

  • 使用maven进行打包mvn package -P jar
  • 将打包的target/ujcms-***.jar文件复制到部署目录。
  • 在部署目录(即ujcms-***.jar所在目录)新建文件夹static
  • src/main/webapp目录下所有文件复制到上一步新建的static目录下。复制完成后,会有类似static/WEB-INF static/templates等文件夹。
  • 在部署目录运行java -jar ujcms-***.jar命令,即可启动。

完整目录结构:

  • ujcms-***.jar
  • static/WEB-INF/...
  • static/templates/...
  • static/uploads/...
  • static/cp/...

关于部署路径

程序通常在部署在Tomcat根目录,首页访问地址类似http://www.mysite.com/ http://localhost/ http://localhost:8080/。在一些特殊的场合,如在Eclipse默认的Tomcat启动方式,可能将程序部署在某一个路径下,首页访问地址类似http://www.mysite.com/ujcms/ http://localhost/ujcms/ http://localhost:8080/ujcms/。此时访问网站前台会出现样式不能正常显示的情况,可以到后台配置 - 全局设置中设置上下文路径,类似为/ujcms,其中斜杠/不能省略,ujcms为部署目录的路径,如在开发环境,则通常为项目名。

开发环境要避免使用上下文路径,除非网站正式部署时也要部署到相应的路径下,否则在开发环境下上传的图片部署到正式环境时,不能正常显示。因为上传图片时,图片地址会带有上下文路径的信息(如:/ujcms/uploads/...)。

Eclipse默认的tomcat启动方式会将程序部署到特定目录再启动,并不是直接在项目所在目录启动tomcat,这时上传的图片(包括通过系统后台新增和修改的模板)也保存在特定的部署目录,并不会保存在程序所在的目录。当修改了Eclipse源代码或文件,会自动重新部署程序,之前上传的图片会被清空。如果发现在开发环境下上传的图片突然都找不到了,很可能就是这个原因。

综上所述,强烈建议使用之前启动程序中介绍的方式启动程序。

前台模板

网站前台模板位于/src/main/webapp/templates目录,使用Freemarker技术。通过修改模板文件,可以完全控制网站页面显示的内容。

后端技术

  • Spring Boot:提供了对Spring开箱即用的功能。简化了Spring配置,提供自动配置auto-configuration功能。
  • Spring MVC:MVC框架,使用方便,Bug较少。
  • Spring Security:安全组件。
  • MyBatis:持久化框架。
  • Lucene:全文检索组件。

后台前端技术

  • TypeScript: JavaScript的一个超集。
  • Vue3:JavaScript框架。
  • ElementPlus:Vue 3 UI 框架。
  • Vite: 下一代前端开发与构建工具。
  • Tailwind CSS: 功能类优先的 CSS 框架。
  • VueRouter: Vue 路由组件。
  • VueI18n: Vue 国际化组件。
  • Tinymce: 富文本编辑器。

网站前端技术

网站前端技术可以使用传统的HTML(Freemarker),通过UJCMS提供的Freemarker的自定义标签获取数据;也可以使用前后端分离的vue或react,通过调用API获取数据。

由于前后端分离的方式对搜索引擎不友好,对于需要通过搜索引擎推广的网站不建议采用。

演示站使用传统的HTML(Freemarker),使用到以下一些技术:

  • Freemarker
  • HTML、CSS、JS
  • Bootstrap
  • JQuery
  • Axios

目录结构

  • src
    • main
      • java
        • com/ujcms/cms
          • core
            • domain:实体类
            • generator:生成功能(包括静态页生成,全文索引生成)
            • listener:监听类(包括数据删除的监听)
            • lucene:全文检索功能
            • mapper:MyBatis Mapper Java 文件
            • security:安全相关功能
            • service:服务层功能
            • support:各种支持类
            • web
              • api:前台API接口
              • backendapi:后台API接口
              • directive:前台Freemarker自定义标签
              • frontend:前台页面Controller
              • support:Web支持类(包括web拦截器等)
            • ContextConfig.java:Context配置类
            • LuceneConfig.java:全文索引配置类
            • ShiroConfig.java:Shiro安全配置类
            • TaskExecutorConfig.java:任务执行器配置类
          • Application.java 启动类
        • com/ujcms/util:公共工具类
      • resources
        • com/ujcms/cms/core/mapper:MyBatis Mapper XML 配置文件。
        • db
          • changelog:数据库表结构更新日志文件。
          • data.mysql.sql:数据库初始化数据SQL脚本。
        • application.yaml:程序配置文件。包括数据库URL、数据库用户名、数据库密码等信息。
        • messages.properties:国际化资源文件。
      • webapp:
        • cp:后台前端页面。
        • templates:网站前台模板。
        • uploads:用户上传文件。
        • WEB-INF/lucene:全文检索索引文件。
  • .editorconfig:设置编辑器文件的格式,如缩进方式、最大行数等。
  • .gitignore:设置不需要提交到git管理的文件和目录。
  • CHANGELOG.md:版本更新日志。
  • LICENSE:许可协议。
  • gulpfile.js:前台构建文件。具有拷贝jquery、bootstrap等文件至前台模板目录/src/main/webapp/template/1/default/_files等功能。
  • package.json:前台模板依赖的js、css组件,如jquery、bootstrap等。
  • pom.xml:Maven配置文件。
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2021-2024 南昌蓝智科技有限公司 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Java开源网站内容管理系统(java cms)。使用SpringBoot、MyBatis、Vue3、ElementPlus、Vite、TypeScript等技术开发。 展开 收起
Apache-2.0
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/ujcms/ujcms.git
git@gitee.com:ujcms/ujcms.git
ujcms
ujcms
ujcms
master

搜索帮助