1、Aexlor概述
Axelor Open Suite 一款 法国开源的OA 项目框架 : Axelor Open Suite 关注业务流程,减少了开发的复杂度,帮助我们快速构建应用。它是一款 MVC 框架,需要我们写很少量的 java 代码,因为它的 models,views, actions 都是在 xml 文件中定义的,框架会自动帮我们生成各部分的代码,大大提高了开发效率,只有少量的业务代码需要我们开发。功能已 “app” 的形式存在,支持安装和卸载操作。框架的文档特别丰富,并且讲的特别详细,是个不错的学习项目。
Axelor Open Suite 包括以下默认模块: 客户关系管理 、销售管理 、财务和成本管理 、人力资源管理 、项目管理、库存和供应链管理、生产管理、多公司,多币种和多语言。
Axelor是框架,你的代码托管在Axelor中,调用的主动权在Axelor手中;代码,资源需要符合Axelor的约定才能被Axelor发现和使用;并且可以通过IOC容器的方式替换Axelor的功能项。具体可以参考Axelor的官方文档:
Axelor官网:https://www.axelor.com
Axelor文档:https://docs.axelor.com
Axelor代码库:https://github.com/axelor
2、Aexlor构建
2.1 Axelor项目结构
2.2 环境准备:
- Java 8, Aexlor只支持java8
- Gradle 构建工具:通过Gradle构建脚本来组织项目
- IDE或者VS编辑器
- SQL数据库系统,本章采用PostgreSQL,其他Mysql、Oracle都OK
- 数据库客户端PgAdmin
2.3 创建项目骨架
1、数据库创建用户和空库
2、增加application.properties配置,设置数据库配置
# Application Information
application.name = Axelor Demo
application.description = Axelor Demo
application.version = 0.1.0
# Default Locale (language)
# Set default application locale (en, fr, fr_FR, en_US)
application.locale = zh_CN
# HERE
# PostgreSQL
db.default.driver = org.postgresql.Driver
db.default.ddl = update
db.default.url = jdbc:postgresql://localhost:5432/axelor-demo-db
db.default.user = postgres
db.default.password = postgres
# Date Format
# ~~~~~
date.format = yyyy/MM/dd
# Timezone
# ~~~~~
date.timezone = Asia/Shanghai
# Session timeout (in minutes)
# ~~~~~
session.timeout = 60
# Storage path for upload files (attachments)
# ~~~~~
# use {user.home} key to save files under user home directory, or
# use absolute path where server user have write permission.
file.upload.dir = {user.home}/.axelor/attachments
# Maximum upload size (in MB)
# ~~~~~
file.upload.size = 5
# The external report design directory
# ~~~~~
# this directory is searched for the rptdesign files
# (fallbacks to designs provided by modules)
reports.design.dir = {user.home}/.axelor/reports
# Storage path for report outputs
reports.output.dir = {user.home}/.axelor/reports-gen
# Data export (csv) encoding
# ~~~~
# Use Windows-1252, ISO-8859-1 or ISO-8859-15 if targeting ms excel
# (excel does not recognize utf8 encoded csv)
data.export.encoding = UTF-8
# Storage path for export action
# ~~~~~
data.export.dir = {user.home}/.axelor/data-export
# Specify whether to import demo data
# ~~~~~
data.import.demo-data = true
# Storage path for templates
# ~~~~~
template.search.dir = {user.home}/.axelor/templates
# LDAP Configuration
# ~~~~~
#ldap.server.url = ldap://localhost:10389
# can be "simple" or "CRAM-MD5"
ldap.auth.type = simple
ldap.system.user = uid=admin,ou=system
ldap.system.password = secret
# group search base
ldap.group.base = ou=groups,dc=example,dc=com
# if set, create groups on ldap server under ldap.group.base
#ldap.group.object.class = groupOfUniqueNames
# a template to search groups by user login id
ldap.group.filter = (uniqueMember=uid={0})
# user search base
ldap.user.base = ou=users,dc=example,dc=com
# a template to search user by user login id
ldap.user.filter = (uid={0})
# Specify whether to enable quartz scheduler
quartz.enable = false
# total number of threads in quartz thread pool
# the number of jobs that can run simultaneously
quartz.threadCount = 3
# View configuration
# ~~~~~
# Set to true to enable single view mode
view.single.tab = false
# Set menu style (left, top, both)
view.menubar.location = both
# HERE
view.toolbar.titles = true
# Global logging
logging.level.root = ERROR
# Axelor logging
# Log everything.
logging.level.com.axelor = INFO
3、增加JPA的persistence.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<!--
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/axelor-app" />
-->
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<!-- value="create" to build a new database on each run;
value="update" to modify an existing database;
value="create-drop" means the same as "create" but also drops tables when Hibernate closes;
value="validate" makes no changes to the database -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<!-- connection pooling -->
<property name="hibernate.connection.provider_class"
value="org.hibernate.hikaricp.internal.HikariCPConnectionProvider" />
<property name="hibernate.hikari.minimumIdle" value="10" />
<property name="hibernate.hikari.maximumPoolSize" value="200" />
<property name="hibernate.hikari.idleTimeout" value="30000" />
</properties>
</persistence-unit>
</persistence>
4、新建一个基于Gradle的java项目,并设置build.gradle和settings.gradle文件
build.gradle文件:
buildscript {
ext.repos = {
// 最优先检查本地 Maven 仓库
mavenLocal()
// 公共仓库优先使用阿里云的
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/jcenter'}
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
// 使用 Axelor 官方的 Repo 放在下面,以便补充缺少的 JAR
maven { url 'https://repository.axelor.com/nexus/public/' }
// 原始的 Maven 仓库放在最后,可以不用,因为阿里云的仓库是镜像同步的
/*
mavenCentral()
jcenter()
maven { url 'https://plugins.gradle.org/m2/'}
*/
}
repositories repos
dependencies {
classpath 'com.axelor:axelor-gradle:5.3.0-SNAPSHOT'
}
}
allprojects {
repositories repos
}
apply plugin: 'com.axelor.app'
axelor {
title = 'axelor-emo'
}
allprojects {
apply plugin: 'idea'
group 'rachel'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
dependencies {
compile project(":modules:sales")
}
wrapper {
gradleVersion = "5.6.4"
}
settings.gradle文件:
rootProject.name = 'rachel-sales-demo'
include "modules:sales"
5、增加根目录gradle.properties文件,设置Gradle编译运行参数
org.gradle.daemon=false
6、启动运行,按照输出url浏览器打开即可看到Axelor界面
登录账户:admin/admin