Total Pageviews

Showing posts with label spring. Show all posts
Showing posts with label spring. Show all posts

Monday, 29 April 2024

Spring-AI

 An Application Framework for AI Engineering.

https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/index.html

 build status

Welcome to the Spring AI project!

The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.

Let's make your @Beans intelligent!

For further information go to our Spring AI reference documentation.

Project Links

Educational Resources

Some selected videos. Search YouTube! for more.

  • Spring Tips: Spring AI
    Watch Spring Tips video
  • Overview of Spring AI @ Devoxx 2023
    Watch the Devoxx 2023 video
  • Introducing Spring AI - Add Generative AI to your Spring Applications
    Watch the video

Getting Started

Please refer to the Getting Started Guide for instruction on adding your dependencies.

Note, the new Spring CLI project lets you get up and running in two simple steps, described in detail here.

  1. Install Spring CLI
  2. Type spring boot new --from ai --name myai in your terminal

Adding Dependencies manually

Note that are two main steps.

  1. Add the Spring Milestone and Snapshot repositories to your build system.
  2. Add the Spring AI BOM
  3. Add dependencies for the specific AI model, Vector Database or other component dependencies you require.

Overview

Despite the extensive history of AI, Java's role in this domain has been relatively minor. This is mainly due to the historical reliance on efficient algorithms developed in languages such as C/C++, with Python serving as a bridge to access these libraries. The majority of ML/AI tools were built around the Python ecosystem. However, recent progress in Generative AI, spurred by innovations like OpenAI's ChatGPT, has popularized the interaction with pre-trained models via HTTP. This eliminates much of the dependency on C/C++/Python libraries and opens the door to the use of programming languages such as Java.

The Python libraries LangChain and LlamaIndex have become popular to implement Generative AI solutions and can be implemented in other programming languages. These Python libraries share foundational themes with Spring projects, such as:

  • Portable Service Abstractions
  • Modularity
  • Extensibility
  • Reduction of boilerplate code
  • Integration with diverse data sources
  • Prebuilt solutions for common use cases

Taking inspiration from these libraries, the Spring AI project aims to provide a similar experience for Spring developers in the AI domain.

Note, that the Spring AI API is not a direct port of either LangChain or LlamaIndex. You will see significant differences in the API if you are familiar with those two projects, though concepts and ideas are fairly portable.

Feature Overview

This is a high level feature overview. The features that are implemented lay the foundation, with subsequent more complex features building upon them.

You can find more details in the Reference Documentation

Interacting with AI Models

ChatClient: A foundational feature of Spring AI is a portable client API for interacting with generative AI models. With this portable API, you can initially target one AI chat model, for example OpenAI and then easily swap out the implementation to another AI chat model, for example Amazon Bedrock's Anthropic Model. When necessary, you can also drop down to use non-portable model options.

Spring AI supports many AI models. For an overview see here. Specific models currently supported are

  • OpenAI
  • Azure OpenAI
  • Amazon Bedrock (Anthropic, Llama, Cohere, Titan, Jurassic2)
  • HuggingFace
  • Google VertexAI (PaLM2, Gemini)
  • Mistral AI
  • Stability AI
  • Ollama
  • PostgresML
  • Transformers (ONNX)
  • Anthropic Claude3

Prompts: Central to AI model interaction is the Prompt, which provides specific instructions for the AI to act upon. Crafting an effective Prompt is both an art and science, giving rise to the discipline of "Prompt Engineering". These prompts often leverage a templating engine for easy data substitution within predefined text using placeholders.

Explore more on Prompts in our concept guide. To learn about the Prompt class, refer to the Prompt API guide.

Prompt Templates: Prompt Templates support the creation of prompts, particularly when a Template Engine is employed.

Delve into PromptTemplates in our concept guide. For a hands-on guide to PromptTemplate, see the PromptTemplate API guide.

Output Parsers: AI model outputs often come as raw java.lang.String values. Output Parsers restructure these raw strings into more programmer-friendly formats, such as CSV or JSON.

Get insights on Output Parsers in our concept guide.. For implementation details, visit the OutputParser API guide.

Incorporating your data

Incorporating proprietary data into Generative AI without retraining the model has been a breakthrough. Retraining models, especially those with billions of parameters, is challenging due to the specialized hardware required. The 'In-context' learning technique provides a simpler method to infuse your pre-trained model with data, whether from text files, HTML, or database results. The right techniques are critical for developing successful solutions.

Retrieval Augmented Generation

Retrieval Augmented Generation, or RAG for short, is a pattern that enables you to bring your data to pre-trained models. RAG excels in the 'query over your docs' use-case.

Learn more about Retrieval Augmented Generation.

Bringing your data to the model follows an Extract, Transform, and Load (ETL) pattern. The subsequent classes and interfaces support RAG's data preparation.

Documents:

The Document class encapsulates your data, including text and metadata, for the AI model. While a Document can represent extensive content, such as an entire file, the RAG approach segments content into smaller pieces for inclusion in the prompt. The ETL process uses the interfaces DocumentReader, DocumentTransformer, and DocumentWriter, ending with data storage in a Vector Database. This database later discerns the pieces of data that are pertinent to a user's query.

Document Readers:

Document Readers produce a List<Document> from diverse sources like PDFs, Markdown files, and Word documents. Given that many sources are unstructured, Document Readers often segment based on content semantics, avoiding splits within tables or code sections. After the initial creation of the List<Document>, the data flows through transformers for further refinement.

Document Transformers:

Transformers further modify the List<Document> by eliminating superfluous data, like PDF margins, or appending metadata (e.g., primary keywords or summaries). Another critical transformation is subdividing documents to fit within the AI model's token constraints. Each model has a context-window indicating its input and output data limits. Typically, one token equates to about 0.75 words. For instance, in model names like gpt-4-32k, "32K" signifies the token count.

Document Writers:

The final ETL step within RAG involves committing the data segments to a Vector Database. Though the DocumentWriter interface isn't exclusively for Vector Database writing, it the main type of implementation.

Vector Stores: Vector Databases are instrumental in incorporating your data with AI models. They ascertain which document sections the AI should use for generating responses. Examples of Vector Databases include Chroma, Postgres, Pinecone, Qdrant, Weaviate, Mongo Atlas, and Redis. Spring AI's VectorStore abstraction permits effortless transitions between database implementations.

Cloning the repo

This repository contains large model files. To clone it you have to either:

  • Ignore the large files (won't affect the spring-ai behaviour) : GIT_LFS_SKIP_SMUDGE=1 git clone git@github.com:spring-projects/spring-ai.git.
  • Or install the Git Large File Storage before cloning the repo.

Building

To build with running unit tests

./mvnw clean package

To build including integration tests. Set API key environment variables for OpenAI and Azure OpenAI before running.

./mvnw clean verify -Pintegration-tests

To run a specific integration test allowing for up to two attempts to succeed. This is useful when a hosted service is not reliable or times out.

./mvnw -pl vector-stores/spring-ai-pgvector-store -Pintegration-tests -Dfailsafe.rerunFailingTestsCount=2 -Dit.test=PgVectorStoreIT verify

To build the docs

./mvnw -pl spring-ai-docs antora

The docs are then in the directory spring-ai-docs/target/antora/site/index.html

To reformat using the java-format plugin

./mvnw spring-javaformat:apply

To update the year on license headers using the license-maven-plugin

./mvnw license:update-file-header -Plicense

To check javadocs using the javadoc:javadoc

./mvnw javadoc:javadoc -Pjavadoc
from https://github.com/spring-projects/spring-ai 
-------------------------------------------------------

Getting Started

This section offers jumping off points for how to get started using Spring AI.

You should follow the steps in each of the following section according to your needs.

Spring CLI

The Spring CLI, simplifies creating new applications directly from your terminal. Like the 'create-react-app' command for those familiar with the JavaScript ecosystem, Spring CLI provides a spring boot new command to create Spring-based projects. Spring CLI also offers features to integrate external code bases into your current project, and many other productivity features.


It is important to understand that the "Spring CLI" is a distinct project from the "Spring Boot CLI", each with its own set of functionalities.

To begin creating a Spring AI application, follow these steps:

  1. Download the latest Spring CLI Release and follow the installation instructions.

  2. To create a simple OpenAI-based application, use the command:

    spring boot new --from ai --name myai
  1. Consult the generated README.md file for guidance on obtaining an OpenAI API Key and running your first AI application.

To add the same simple AI application to an existing project, execute:

spring boot add ai

Spring CLI allows users to define their own project catalogs that define which projects you can create or add to your existing code base.

Spring Initializr

Head on over to start.spring.io and select the AI Models and Vector Stores that you want to use in your new applications.

Add Milestone and Snapshot Repositories

If you prefer to add the dependency snippets by hand, follow the directions in the following sections.

To use the Milestone and Snapshot version, you need to add references to the Spring Milestone and/or Snapshot repositories in your build file.

For Maven, add the following repository definitions as needed:

  <repositories>
    <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>spring-snapshots</id>
      <name>Spring Snapshots</name>
      <url>https://repo.spring.io/snapshot</url>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

For Gradle, add the following repository definitions as needed:

repositories {
  mavenCentral()
  maven { url 'https://repo.spring.io/milestone' }
  maven { url 'https://repo.spring.io/snapshot' }
}

Dependency Management

The Spring AI Bill of Materials (BOM) declares the recommended versions of all the dependencies used by a given release of Spring AI. Using the BOM from your application’s build script avoids the need for you to specify and maintain the dependency versions yourself. Instead, the version of the BOM you’re using determines the utilized dependency versions. It also ensures that you’re using supported and tested versions of the dependencies by default, unless you choose to override them.

If you’re a Maven user, you can use the BOM by adding the following to your pom.xml file -

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-bom</artifactId>
            <version>0.8.1-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Gradle users can also use the Spring AI BOM by leveraging Gradle (5.0+) native support for declaring dependency constraints using a Maven BOM. This is implemented by adding a 'platform' dependency handler method to the dependencies section of your Gradle build script. As shown in the snippet below this can then be followed by version-less declarations of the Starter Dependencies for the one or more spring-ai modules you wish to use, e.g. spring-ai-openai.

dependencies {
  implementation platform("org.springframework.ai:spring-ai-bom:0.8.1-SNAPSHOT")
  // Replace the following with the starter dependencies of specific modules you wish to use
  implementation 'org.springframework.ai:spring-ai-openai'
}

Add dependencies for specific components

Each of the following sections in the documentation shows which dependencies you need to add to your project build system.

Chat Models

 

 

Tuesday, 14 June 2022

spring-cloud-vue

 cloud-vue是一套基于springcloud + mybatis + vue全家桶(Vue2.x + Vue-router2.x + Vuex)的前后端分离框架. 使用Maven对项目进行模块化管理,提高项目的易开发性、扩展性。 系统包括分布式配置、eureka注册中心、服务中心、zipkin分布式跟踪等。 每个模块服务多系统部署,注册到同一个eureka集群服务注册中心,实现集群部署。

项目简介

  • cloud-vue是一套基于springcloud + mybatis + vue全家桶(Vue2.x + Vue-router2.x + Vuex)的前后端分离框架.
  • 使用Maven对项目进行模块化管理,提高项目的易开发性、扩展性。
  • 系统包括分布式配置、eureka注册中心、服务中心、zipkin分布式跟踪等。
  • 每个模块服务多系统部署,注册到同一个eureka集群服务注册中心,实现集群部署。

主要功能

  • 登录、退出登录
  • 修改密码、记住密码
  • 菜单管理
  • 系统参数
  • 权限节点
  • 岗位管理
  • 部门管理
  • 用户组管理
  • 用户管理

依赖

java后端依赖环境

  • Maven 3
  • Java 8
  • MySQL 5.7

vue2前端依赖环境

工程说明

  • cloud-config-server:配置中心。
  • cloud-eureka-server:注册中心。
  • cloud-simple-service:自定义的微服务。
  • cloud-zipkin-ui:分布式链路调用监控系统,聚合各业务系统调用延迟数据,达到链路调用监控跟踪。
  • cloud-vue : vue(Vue2.x + Vue-router2.x + Vuex)的前端项目

部署说明

  • 导入cloud-simple-service的cloud-vue.sql到mysql数据库。
  • 修改cloud-config-repo与cloud-zipkin-ui中的数据库配置文件
  • 打包命令 mvn package -DskipDockerBuild
  • 依次启动cloud-eureka-server-1.0.0.jar、cloud-config-server-1.0.0.jar、cloud-zipkin-ui-1.0.0.jar、cloud-simple-service-1.0.0.jar。
  • 端口:配置中心端口(1111)、注册中心(8888)、rest服务(80)、zipkin服务(9012)、UI前端(8080),如果端口冲突请自行修改。

from https://github.com/OptionalDay/spring-cloud-vue

 

基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构zheng

提供整套公共微服务服务模块:集中权限管理(单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。 

 

前言

  zheng项目不仅仅是一个开发架构,而是努力打造一套从 前端模板 - 基础框架 - 分布式架构 - 开源项目 - 持续集成 - 自动化部署 - 系统监测 - 无缝升级 的全方位J2EE企业级开发解决方案。

项目介绍

  基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构,提供整套公共微服务服务模块:内容管理、支付中心、用户管理(包括第三方)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。

组织结构

zheng
├── zheng-common -- SSM框架公共模块
├── zheng-admin -- 后台管理模板
├── zheng-ui -- 前台thymeleaf模板[端口:1000]
├── zheng-config -- 配置中心[端口:1001]
├── zheng-upms -- 用户权限管理系统
|    ├── zheng-upms-common -- upms系统公共模块
|    ├── zheng-upms-dao -- 代码生成模块,无需开发
|    ├── zheng-upms-client -- 集成upms依赖包,提供单点认证、授权、统一会话管理
|    ├── zheng-upms-rpc-api -- rpc接口包
|    ├── zheng-upms-rpc-service -- rpc服务提供者
|    └── zheng-upms-server -- 用户权限系统及SSO服务端[端口:1111]
├── zheng-cms -- 内容管理系统
|    ├── zheng-cms-common -- cms系统公共模块
|    ├── zheng-cms-dao -- 代码生成模块,无需开发
|    ├── zheng-cms-rpc-api -- rpc接口包
|    ├── zheng-cms-rpc-service -- rpc服务提供者
|    ├── zheng-cms-search -- 搜索服务[端口:2221]
|    ├── zheng-cms-admin -- 后台管理[端口:2222]
|    ├── zheng-cms-job -- 消息队列、任务调度等[端口:2223]
|    └── zheng-cms-web -- 网站前台[端口:2224]
├── zheng-pay -- 支付系统
|    ├── zheng-pay-common -- pay系统公共模块
|    ├── zheng-pay-dao -- 代码生成模块,无需开发
|    ├── zheng-pay-rpc-api -- rpc接口包
|    ├── zheng-pay-rpc-service -- rpc服务提供者
|    ├── zheng-pay-sdk -- 开发工具包
|    ├── zheng-pay-admin -- 后台管理[端口:3331]
|    └── zheng-pay-web -- 演示示例[端口:3332]
├── zheng-ucenter -- 用户系统(包括第三方登录)
|    ├── zheng-ucenter-common -- ucenter系统公共模块
|    ├── zheng-ucenter-dao -- 代码生成模块,无需开发
|    ├── zheng-ucenter-rpc-api -- rpc接口包
|    ├── zheng-ucenter-rpc-service -- rpc服务提供者
|    └── zheng-ucenter-web -- 网站前台[端口:4441]
├── zheng-wechat -- 微信系统
|    ├── zheng-wechat-mp -- 微信公众号管理系统
|    |    ├── zheng-wechat-mp-dao -- 代码生成模块,无需开发
|    |    ├── zheng-wechat-mp-service -- 业务逻辑
|    |    └── zheng-wechat-mp-admin -- 后台管理[端口:5551]
|    └── zheng-ucenter-app -- 微信小程序后台
├── zheng-api -- API接口总线系统
|    ├── zheng-api-common -- api系统公共模块
|    ├── zheng-api-rpc-api -- rpc接口包
|    ├── zheng-api-rpc-service -- rpc服务提供者
|    └── zheng-api-server -- api系统服务端[端口:6666]
├── zheng-oss -- 对象存储系统
|    ├── zheng-oss-sdk -- 开发工具包
|    ├── zheng-oss-web -- 前台接口[端口:7771]
|    └── zheng-oss-admin -- 后台管理[端口:7772]
├── zheng-message -- 实时通知系统
|    ├── zheng-message-sdk -- 开发工具包
|    ├── zheng-message-server -- 服务端[端口:8881,SocketIO端口:8882]
|    └── zheng-message-client -- 客户端
├── zheng-shop -- 电子商务系统
└── zheng-demo -- 示例模块(包含一些示例代码等)
     ├── zheng-demo-rpc-api -- rpc接口包
     ├── zheng-demo-rpc-service -- rpc服务提供者
     └── zheng-demo-web -- 演示示例[端口:9999]

技术选型

后端技术:

技术 名称 官网
Spring Framework 容器 http://projects.spring.io/spring-framework/
SpringMVC MVC框架 http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc
Apache Shiro 安全框架 http://shiro.apache.org/
Spring session 分布式Session管理 http://projects.spring.io/spring-session/
MyBatis ORM框架 http://www.mybatis.org/mybatis-3/zh/index.html
MyBatis Generator 代码生成 http://www.mybatis.org/generator/index.html
PageHelper MyBatis物理分页插件 http://git.oschina.net/free/Mybatis_PageHelper
Druid 数据库连接池 https://github.com/alibaba/druid
FluentValidator 校验框架 https://github.com/neoremind/fluent-validator
Thymeleaf 模板引擎 http://www.thymeleaf.org/
Velocity 模板引擎 http://velocity.apache.org/
ZooKeeper 分布式协调服务 http://zookeeper.apache.org/
Dubbo 分布式服务框架 http://dubbo.io/
TBSchedule & elastic-job 分布式调度框架 https://github.com/dangdangdotcom/elastic-job
Redis 分布式缓存数据库 https://redis.io/
Solr & Elasticsearch 分布式全文搜索引擎 http://lucene.apache.org/solr/ https://www.elastic.co/
Quartz 作业调度框架 http://www.quartz-scheduler.org/
Ehcache 进程内缓存框架 http://www.ehcache.org/
ActiveMQ 消息队列 http://activemq.apache.org/
JStorm 实时流式计算框架 http://jstorm.io/
FastDFS 分布式文件系统 https://github.com/happyfish100/fastdfs
Log4J 日志组件 http://logging.apache.org/log4j/1.2/
Swagger2 接口测试框架 http://swagger.io/
sequence 分布式高效ID生产 http://git.oschina.net/yu120/sequence
AliOSS & Qiniu & QcloudCOS 云存储 https://www.aliyun.com/product/oss/ http://www.qiniu.com/ https://www.qcloud.com/product/cos
Protobuf & json 数据序列化 https://github.com/google/protobuf
Jenkins 持续集成工具 https://jenkins.io/index.html
Maven 项目构建管理 http://maven.apache.org/
Netty-socketio 实时推送 https://github.com/mrniko/netty-socketio

前端技术:

技术 名称 官网
jQuery 函式库 http://jquery.com/
Bootstrap 前端框架 http://getbootstrap.com/
Bootstrap-table Bootstrap数据表格 http://bootstrap-table.wenzhixin.net.cn/
Font-awesome 字体图标 http://fontawesome.io/
material-design-iconic-font 字体图标 https://github.com/zavoloklom/material-design-iconic-font
Waves 点击效果插件 https://github.com/fians/Waves
zTree 树插件 http://www.treejs.cn/v3/
Select2 选择框插件 https://github.com/select2/select2
jquery-confirm 弹出窗口插件 https://github.com/craftpip/jquery-confirm
jQuery EasyUI 基于jQuery的UI插件集合体 http://www.jeasyui.com
React 界面构建框架 https://github.com/facebook/react
Editor.md Markdown编辑器 https://github.com/pandao/editor.md
zhengAdmin 后台管理系统模板 https://github.com/shuzheng/zhengAdmin
autoMail 邮箱地址自动补全插件 https://github.com/shuzheng/autoMail
zheng.jprogress.js 加载进度条插件 https://github.com/shuzheng/zheng.jprogress.js
zheng.jtotop.js 返回顶部插件 https://github.com/shuzheng/zheng.jtotop.js
socket.io.js SocketIO插件 https://socket.io/

模块介绍

zheng-common

Spring+SpringMVC+Mybatis框架集成公共模块,包括公共配置、MybatisGenerator扩展插件、通用BaseService、工具类等。

zheng-admin

基于bootstrap实现的响应式Material Design风格的通用后台管理系统,zheng项目所有后台系统都是使用该模块界面作为前端展示。

zheng-ui

各个子系统前台thymeleaf模板,前端资源模块,使用nginx代理,实现动静分离。

zheng-upms

本系统是基于RBAC授权和基于用户授权的细粒度权限控制通用平台,并提供单点登录、会话管理和日志管理。接入的系统可自由定义组织、角色、权限、资源等。用户权限=所拥有角色权限合集+用户加权限-用户减权限,优先级:用户减权限>用户加权限>角色权限

zheng-oss

文件存储系统,提供四种方案:

  • 阿里云 OSS
  • 腾讯云 COS
  • 七牛云
  • 本地分布式存储

阿里云OSS

zheng-api

服务网关,对外暴露统一规范的接口和包装响应结果,包括各个子系统的交互接口、对外开放接口、开发加密接口、接口文档等服务,可在该模块支持验签、鉴权、路由、限流、监控、容错、日志等功能。示例图:

API网关

zheng-cms

内容管理系统:支持多标签、多类目、强大评论的内容管理,有基本单页展示,菜单管理,系统设置等功能。

zheng-pay

  • 一站式支付解决方案,统一下单接口,支持支付宝、微信、网银等多种支付方式。不涉及业务的纯粹的支付平台。

  • 统一下单(统一下单接口、统一扫码)、订单管理、数据分析、财务报表、商户管理、渠道管理、对账系统、系统监控。

统一扫码支付

zheng-ucenter

通用用户管理系统, 实现最常用的用户注册、登录、资料管理、个人中心、第三方登录等基本需求,支持扩展二次开发。

zheng-wechat-mp

微信公众号管理平台,除实现官网后台自动回复、菜单管理、素材管理、用户管理、消息群发等基础功能外,还有二维码推广、营销活动、微网站、会员卡、优惠券等。

zheng-wechat-app

微信小程序后台

zheng-message

基于Netty实现SocketIO的实时推送系统。支持命名空间、二进制数据、SSL、ACK等功能。

环境搭建(QQ群内有“zheng环境搭建和系统部署文档.doc”)

开发工具:

  • MySql: 数据库
  • jetty: 开发服务器
  • Tomcat: 应用服务器
  • SVN|Git: 版本管理
  • Nginx: 反向代理服务器
  • Varnish: HTTP加速器
  • IntelliJ IDEA: 开发IDE
  • PowerDesigner: 建模工具
  • Navicat for MySQL: 数据库客户端

开发环境:

  • Jdk7+
  • Mysql5.5+
  • Redis
  • Zookeeper
  • ActiveMQ
  • Dubbo-admin
  • Dubbo-monitor

工具安装

环境搭建和系统部署文档(作者:小兵,QQ群共享提供下载)

资源下载

开发指南:

  • 1、本机安装Jdk7、Mysql、Redis、Zookeeper、ActiveMQ并启动相关服务,使用默认配置默认端口即可
  • 2、克隆源代码到本地并打开,推荐使用IntelliJ IDEA,本地编译并安装到本地maven仓库

修改本地Host

  • 127.0.0.1 ui.zhangshuzheng.cn

  • 127.0.0.1 upms.zhangshuzheng.cn

  • 127.0.0.1 cms.zhangshuzheng.cn

  • 127.0.0.1 pay.zhangshuzheng.cn

  • 127.0.0.1 ucenter.zhangshuzheng.cn

  • 127.0.0.1 wechat.zhangshuzheng.cn

  • 127.0.0.1 api.zhangshuzheng.cn

  • 127.0.0.1 oss.zhangshuzheng.cn

  • 127.0.0.1 config.zhangshuzheng.cn

  • 127.0.0.1 zkserver

  • 127.0.0.1 rdserver

  • 127.0.0.1 dbserver

  • 127.0.0.1 mqserver

编译流程

maven编译安装zheng/pom.xml文件即可

启动顺序(后台)

准备工作

  • 新建zheng数据库,导入project-datamodel文件夹下的zheng.sql

  • 修改各dao模块和rpc-service模块的redis.properties、jdbc.properties、generator.properties数据库连接等配置信息,其中master.redis.password、master.jdbc.password、slave.jdbc.password、generator.jdbc.password密码值使用了AES加密,请使用com.zheng.common.util.AESUtil工具类修改这些值

  • 启动Zookeeper、Redis、ActiveMQ、Nginx(配置文件参考project-tools/nginx下的*.conf文件)

zheng-upms

  • 首先启动 zheng-upms-rpc-service(直接运行src目录下的ZhengUpmsRpcServiceApplication#main方法启动) => zheng-upms-server(jetty),然后按需启动对应子系统xxx的zheng-xxx-rpc-service(main方法) => zheng-xxx-webapp(jetty)

启动演示

  • 访问 http://upms.zhangshuzheng.cn:1111/,子系统菜单已经配置到zheng-upms权限中,不用直接访问子系统,默认帐号密码:admin/123456

  • 登录成功后,可在右上角切换已注册系统访问

zheng-cms

  • zheng-cms-admin:启动ActiveMQ-启动 => 启动zheng-rpc-service => 启动zheng-cms-admin

  • zheng-cms-web:启动nginx代理zheng-ui静态资源,配置文件可参考 nginx.conf

zheng-oss

  • 首先启动zheng-oss-web服务

  • 开发阶段,如果zheng-oss-web没有公网域名,推荐使用ngrok内网穿透工具,为开发环境提供公网域名,实现上传回调

  • 启动nginx代理zheng-ui静态资源

    • 启动流程:优先rcp-service服务提供者,再启动其他webapp

    • 扩展流程:可扩展和拆分rpc-api和rpc-service模块,可按微服务拆分或场景拆分

    部署方式(QQ群内有“zheng十分钟视频:从打包到linux服务器部署.wmv”)

  • war包项目:使用tomcat等web容器启动

  • rpc-service服务提供者jar包:将打包后的zheng-xxx-rpc-service-assembly.tar.gz文件解压,使用bin目录的管理脚本运行即可,支持优雅停机。

框架规范约定

约定优于配置(convention over configuration),此框架约定了很多编程规范,下面一一列举:


- service类,需要在叫名`service`的包下,并以`Service`结尾,如`CmsArticleServiceImpl`

- controller类,需要在以`controller`结尾的包下,类名以Controller结尾,如`CmsArticleController.java`,并继承`BaseController`

- spring task类,需要在叫名`task`的包下,并以`Task`结尾,如`TestTask.java`

- mapper.xml,需要在名叫`mapper`的包下,并以`Mapper.xml`结尾,如`CmsArticleMapper.xml`

- mapper接口,需要在名叫`mapper`的包下,并以`Mapper`结尾,如`CmsArticleMapper.java`

- model实体类,需要在名叫`model`的包下,命名规则为数据表转驼峰规则,如`CmsArticle.java`

- spring配置文件,命名规则为`applicationContext-*.xml`

- 类名:首字母大写驼峰规则;方法名:首字母小写驼峰规则;常量:全大写;变量:首字母小写驼峰规则,尽量非缩写

- springmvc配置加到对应模块的`springMVC-servlet.xml`文件里

- 配置文件放到`src/main/resources`目录下

- 静态资源文件放到`src/main/webapp/resources`目录下

- jsp文件,需要在`/WEB-INF/jsp`目录下

- `RequestMapping`和返回物理试图路径的url尽量写全路径,如:`@RequestMapping("/manage")`、`return "/manage/index"`

- `RequestMapping`指定method

- 模块命名为`项目`-`子项目`-`业务`,如`zheng-cms-admin`

- 数据表命名为:`子系统`_`表`,如`cms_article`

- 更多规范,参考[[阿里巴巴Java开发手册] http://git.oschina.net/shuzheng/zheng/attach_files

演示地址

演示地址: http://upms.zhangshuzheng.cn/

拓扑图

拓扑图

常见问题

  • Eclipse下,dubbo找不到dubbo.xsd报错,不影响使用,如果要解决,可参考 http://blog.csdn.net/gjldwz/article/details/50555922

  • 报zheng-xxx.jar包找不到,请按照文档编译顺序,将源代码编译并安装到本地maven仓库

  • zheng-cms-admin启动卡住:因为没有启动activemq

  • zheng-upms-server访问报session不存在:因为没有启动redis服务

  • 界面没有样式:因为zheng-admin没有编译安装到本地仓库

  • linux下执行rpc-service脚本报“bin/bash^M 坏的解释器”,使用sed -i 's/\r$//' filename删除脚本中\r字符

附件

zheng相关博客

优秀文章和博客

在线小工具

在线文档