搭建axelor
- Axelor简介
- 官网地址
- 安装Axelor
- 数据库postgresql
- 安装postgresql
- 安装成功
- 新建gradle项目
- 项目集成Axelor
- 引入依赖
- 修改配置
- 修改gradle-wrapper.properties
- 增加application.properties
- 修改数据库链接地址
- 增加persistence.xml
- 新建数据库
- 启动项目
- 访问项目
Axelor简介
Axelor是基于Java语言,开源的,低代码商业应用模块化开发框架和智能管理平台。
官网地址
官网地址:https://axelor.com/
技术文档:https://docs.axelor.com/adk/5.0/
功能文档:https://docs.axelor.com/abs/5.0/install/index.html
论坛地址:https://forum.axelor.com/
安装Axelor
数据库postgresql
安装postgresql
- 访问PostgreSQL官网here,点击
Download the installer
。 - 下载PostgreSQL 下载得到PostgreSQL安装包。
- 使用管理员运行下载的安装包
选择Yes
会先安装需要的VC++,不用管,等安装完会打开安装界面
点击Next
根据个人需要可以修改安装目录,这里我改到了D盘的根目录下,修改完后点击Next
默认全部勾选,可以根据个人需要取消部分勾选,我选择全部勾选。点击Next
数据存储路径,可根据需要修改,修改完后点击Next
设置数据库密码,设置完成后点击Next
设置端口号,默认5432,可以根据需要修改端口号,修改完后点击Next
设置语言,默认即可,点击Next
配置完毕,确认无误后点击Next,下个页面同样点击Next
开始安装,等待安装结束
安装完成后点击Finish
安装了Stack的话,会弹出下面窗口,该窗口是补充安装其他功能的,不需要其他功能的点击Cancel,然后点击Yes即可。
安装成功
PostgreSQL自带了pgAdmin来操作数据库,打开pgAdmin软件
输入安装的时候设置的密码,点击OK
展开左边Servers区域
再次输入安装的时候设置的密码,勾选Save Password,点击OK
成功连接到PostgreSQL数据库即安装成功
新建gradle项目
使用的开发工具是IDEA,点击 File --> New --> Project
选择Gradle,选择 Project SKD,我使用的是jdk1.8,选择好之后点击Next;
输入创建的项目名称和创建的项目地址,输入完成之后点击 Finish;
项目集成Axelor
引入依赖
在build.gradle文件里增加Axelor的仓库地址和依赖项:
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/' }
jcenter()
mavenCentral()
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-example'
}
allprojects {
apply plugin: 'idea'
group 'example'
version '1.0.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
dependencies {
}
wrapper {
gradleVersion = "5.6.4"
}
修改配置
修改gradle-wrapper.properties
distributionUrl
修改为 https://services.gradle.org/distributions/gradle-5.6.4-bin.zip
增加application.properties
位置如下:src/main/resources/application.properties
具体配置内容可以参考Axelor配置说明,参考地址
。
这里我们把官网给的配置文件内容全部拿过来使用。
application.properties
配置文件:
# Application Information
# ~~~~~
application.name = Axelor DEMO
application.description = The Demo Application
application.version = 1.0.0
# Author/Company
# ~~~~~
application.author = Axelor
application.copyright = Copyright (c) {year} Axelor. All Rights Reserved.
# Header Logo
# ~~~~~
# Should be 40px in height with transparent background
application.logo =
# Home Website
# ~~~~~
# Link to be used with header logo
application.home = http://www.axelor.com
# Link to the online help
# ~~~~~
application.help = http://docs.axelor.com/adk
# Application deployment mode
# ~~~~~
# Set to 'dev' for development mode else 'prod'
application.mode = dev
# CSS Theme
# ~~~~~
# Set default CSS theme, for example `blue`
application.theme =
# Default Locale (language)
# ~~~~~
# Set default application locale (en, fr, fr_FR, en_US)
application.locale =
# Encryption
# ~~~~~
# Set encryption password
encryption.password = MySuperSecretKey
# Set encryption algorithm (CBC or GCM)
#encryption.algorithm = CBC
# Database settings
# ~~~~~
# See hibernate documentation for connection parameters
# PostgreSQL
db.default.driver = org.postgresql.Driver
db.default.ddl = update
db.default.url = jdbc:postgresql://localhost:5432/axelor-example-09
db.default.user = postgres
db.default.password = 123456
# MySQL
#db.default.driver = com.mysql.jdbc.Driver
#db.default.ddl = update
#db.default.url = jdbc:mysql://localhost:3306/axelor_demo_wip
#db.default.user = username
#db.default.password = secret
# Oracle
#db.default.driver = oracle.jdbc.OracleDriver
#db.default.ddl = update
#db.default.url = jdbc:oracle:thin:@localhost:1521:oracle
#db.default.user = username
#db.default.password =
# Date Format
# ~~~~~
date.format = dd/MM/yyyy
# Timezone
# ~~~~~
date.timezone = UTC
# 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
# Upload filename pattern, default is auto where file is save with same name
# in the given upload dir, if file is already there, a count number is
# appended to file name.
#
# This can be overridden by providing custom name pattern, for example:
#
# file.upload.filename.pattern = {year}-{month}/{day}/{name}
# file.upload.filename.pattern = {AA}/{name}
#
# Following placeholders can be used:
#
# {year} - current year
# {month} - current month
# {day} - current day
# {name} - file name
# {A} - first letter from file name
# {AA} - first 2 letter from file name
# {AAA} - first 3 letter from file name
#
#file.upload.filename.pattern = {year}-{month}/{day}/{name}
# Maximum upload size (in MB)
# ~~~~~
file.upload.size = 5
# Whitelist pattern can be used to allow file upload with matching names.
#
# For example: \\.(xml|html|jpg|png|pdf|xsl)$
#
# Regular expression
# ~~~~~
#file.upload.whitelist.pattern = \\.(xml|html|jpg|png|pdf|xsl)$
# Blacklist pattern can be used to block file upload with matching names.
#
# Regular expression
# ~~~~~
#file.upload.blacklist.pattern = ^\\.
# Whitelist content type can be used to allow file upload with matching content.
#
# List of mime-types (plain/text,image/*,video/webm)
# ~~~~~
#file.upload.whitelist.types = plain/text,image/*,video/webm
# Blacklist content type can be used to block file upload with matching content.
#
# List of mime-types (plain/text,image/*,video/webm)
# ~~~~~
#file.upload.blacklist.types =
# 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})
# CAS configuration
# ~~~~~
#auth.cas.server.url.prefix = https://localhost:8443/cas
# use public accessible url
#auth.cas.service = http://localhost:8080/open-platform-demo/cas
# login url, if not given prepared from server & service url
#auth.cas.login.url = https://localhost:8443/cas/login?service=http://localhost:8080/open-platform-demo/cas
# logout url, if not given prepared from server & service url
#auth.cas.logout.url = https://localhost:8443/cas/logout?service=http://localhost:8080/open-platform-demo/
# CAS validation protocol (CAS, SAML)
#auth.cas.protocol = SAML
# the attribute to map to user display name
#auth.cas.attrs.user.name = name
# the attribute to map to user email
#auth.cas.attrs.user.email = mail
# Quartz Scheduler
# ~~~~~
# quartz job scheduler
# 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
# SMPT configuration
# ~~~~~
# SMTP server configuration
#mail.smtp.host = smtp.gmail.com
#mail.smtp.port = 587
#mail.smtp.channel = starttls
#mail.smtp.user = user@gmail.com
#mail.smtp.pass = secret
# timeout settings
#mail.smtp.timeout = 60000
#mail.smtp.connectionTimeout = 60000
# IMAP configuration
# ~~~~~
# IMAP server configuration
# (quartz scheduler should be enabled for fetching stream replies)
#mail.imap.host = imap.gmail.com
#mail.imap.port = 993
#mail.imap.channel = ssl
#mail.imap.user = user@gmail.com
#mail.imap.pass = secret
# timeout settings
#mail.imap.timeout = 60000
#mail.imap.connectionTimeout = 60000
# CORS configuration
# ~~~~~
# CORS settings to allow cross origin requests
# regular expression to test allowed origin or * to allow all (not recommended)
#cors.allow.origin = *
#cors.allow.credentials = true
#cors.allow.methods = GET,PUT,POST,DELETE,HEAD,OPTIONS
#cors.allow.headers = Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers
# View configuration
# ~~~~~
# Set to true to enable single view mode
view.single.tab = false
# Set menu style (left, top, both)
view.menubar.location = both
# Set to false to hide advance search filter share option
#view.adv-search.share = true
# Logging
# ~~~~~
# Custom logback configuration can be provided with `logging.config` property pointing
# to a custom `logback.xml`. In this case, all the logging configuration provided here
# will be ignored.
#
# Following settings can be used to configure logging system automatically.
#
#logging.path = {user.home}/.axelor/logs
#logging.pattern.file = %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%t] %-40.40logger{39} : %m%n
#logging.pattern.console = %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n
# Global logging
logging.level.root = ERROR
# Axelor logging
# Log everything.
logging.level.com.axelor = INFO
# Hibernate logging
# Log everything. Good for troubleshooting
#logging.level.org.hibernate = INFO
# Log all SQL DML statements as they are executed
#logging.level.org.hibernate.SQL = DEBUG
#logging.level.org.hibernate.engine.jdbc = DEBUG
# Log all SQL DDL statements as they are executed
#logging.level.org.hibernate.tool.hbm2ddl = INFO
# Log all JDBC parameters
#logging.level.org.hibernate.type = ALL
# Log transactions
#logging.level.org.hibernate.transaction = DEBUG
# Log L2-Cache
#logging.level.org.hibernate.cache = DEBUG
# Log JDBC resource acquisition
#logging.level.org.hibernate.jdbc = TRACE
#logging.level.org.hibernate.service.jdbc = TRACE
# Log connection pooling
#logging.level.com.zaxxer.hikari = INFO
修改数据库链接地址
修改
application.properties
位置地址:src/main/resources/application.properties修改内容:
db.default.url
修改为自己的数据库的地址db.default.user
修改为自己的数据库的用户名db.default.password
修改为自己的数据库的密码
增加persistence.xml
persistence.xml
位置如下:src/main/resources/META-INF/persistence.xml
persistence.xml内容可以参考官网给的说明,参考地址 here。这里我们把官网给的persistence.xml配置直接拿过来使用。
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> </persistence-unit> </persistence>
新建数据库
在PostgreSQL数据库中新建Axelor连接使用的数据库。
启动项目
需要注意的是如果数据库中没有Axelor需要的表会重新创建表
启动项目
启动成功
访问项目
启动成功后会在控制台输出得到Running at http://localhost:8080/axelor-example
在浏览器访问 http://localhost:8080/axelor-example
项目初始化的时候会默认新建两个用户,对应的数据库表(auth_user),可自己查看
用户1:用户名:admin 密码:admin
用户2:用户名:demo 密码:demo
我们输入admin用户访问系统;