Moqui部署说明
http://www.moqui.org/framework/docs/RunDeploy.html
Running and Deployment Instructions
This document explains how to run Moqui through the executable war file, or by deploying a war file in an application server.
Running and Deployment Instructions
1. Quick Start
2. Runtime Directory and Configuration File
3. Executable WAR File
4. Examples and Common Approaches
Easy Way - Default Settings
Common Alternate - Specify a Configuration File on Command Line
Create a Custom WAR File with Settings Inside
5. Build and Run From Source
6. Project Directory Structure
1. Quick Start
Make sure you have a Java 6 JDK installed (the Sun/Oracle or Apple version is best, haven't tried on OpenJDK or Harmony yet)
Download and unzip the binary distribution, creating a moqui directory
Load the seed and demo data which will create Derby DB and tables:
$ java -jar moqui-<version>.war -load
Run the framework (with embedded Servlet, JTA/CP, DB):
$ java -jar moqui-<version>.war
In your browser (on the same machine) go to:
http://localhost:8080/
For details and other approaches read on...
2. Runtime Directory and Configuration File
The Moqui Framework has two main parts to deploy:
Executable WAR File (see below)
Runtime Directory with Configuration File
However you use the executable WAR file, you must have a runtime directory and you may override default settings with a XML configuration file.
The runtime directory is the main place to put components you want to load, the root files (root screen) for the web application, and configuration files. It is also where the framework will put log files, Derby db files (if you are using Derby), JCR repo files, etc. You will eventually want to create your own runtime directory and keep it in your own source repository and you can use the default project one to get started.
Specify these two properties:
moqui.runtime Runtime directory (defaults to "./runtime" if exists or just "." if there is no runtime sub-directory)
moqui.conf Conf XML file (URL or path relative to moqui.runtime)
There are two ways to specify these two properties:
MoquiInit.properties file on the classpath
System properties specified on the command line (with java -D arguments)
See below for examples.
3. Executable WAR File
Yep, that's right: an executable WAR file. There are 3 main things you can
do with this (with example commands to demonstrate, modify as needed):
Load Data:$ java -jar moqui-<version>.war -load
Run embedded web server:$ java -jar moqui-<version>.war
Deploy as WAR, for Tomcat:$ cp moqui-<version>.war ../tomcat/webapps
You can also display settings and help information with:
java -jar moqui-<version>.war -help
For information about loading only certain files instead of all data files in all components, run that to see the help text.
4. Examples and Common Approaches
Easy Way - Default Settings
The easiest way to run is to have a moqui directory with the moqui.war file and the runtime directory in it. With the binary distribution of Moqui when you unzip the archive this is what you'll have.
To use the default settings:
moqui.runtime = runtime
moqui.conf = conf/MoquiDevConf.xml (relative to runtime)
Run these commands:
Load Data$ java -jar moqui-<version>.war -load
Run Server$ java -jar moqui-<version>.war
Common Alternate - Specify a Configuration File on Command Line
Load Data$ java -Dmoqui.conf=conf/MoquiStagingConf.xml -jar moqui-<version>.war -load
Run Server$ java -Dmoqui.conf=conf/MoquiStagingConf.xml -jar moqui-<version>.war
Create a Custom WAR File with Settings Inside
Add components and other resources as needed to the runtime directory
Change ${moqui.home}/MoquiInit.properties with desired settings
Change Moqui conf file (runtime/conf/Moqui*Conf.xml) as needed
Create a derived WAR file based on the moqui.war file and with your runtime directory contents and MoquiInit.properties file with: "$ gradle addRuntime" OR "$ ant add-runtime"
Copy the created WAR file (moqui-plus-runtime.war) to deployment target
Run server (or restart to deploy live WAR)
5. Build and Run From Source
Moqui Framework uses Gradle for building from source. There are various custom tasks to automate frequent things, but most work is done with the built-in tasks from Gradle.
There is also an Ant build file for a few common tasks, but not for building from source.
Build JAR, WAR$ gradle build
Load All Data$ gradle load$ ant load
Run Embedded Server$ gradle run$ ant run
Clean up JARs, WAR$ gradle clean
Clean up ALL built and runtime files (logs, dbs, etc)$ gradle cleanAll
Note that the load and run tasks depend on the build task. The easiest to get a new development system running with a populated database is:
$ gradle load run
This will build the war file, run the data loader, then run the server. To stop it just press <ctrl-c> (or your preferred alternative).
6. Project Directory Structure
- moqui (from https://github.com/jonesde/moqui)
- framework
- build : Results of framework build go here (classes, jars, etc)
- data : Seed data
- entity : Framework entity definitions
- lib : Libraries (JAR files) used in Moqui
- screen : Framework screens
- service : Framework services
- src : Java API, standard entities, services, data, XSDs, etc
- api : Java source for the Moqui Framework API
- main : Main implement source
- groovy : Groovy source (bulk of the implementation)
- java : Java source (a few special classes)
- resources : Classpath resources, placed in JAR as-is
- webapp : Base webapp, mostly just a WEB-INF/web.xml file
- start : Java source for MoquiStart, used for executable WAR
- template : Framework templates (screen/form, xml-actions FTLs)
- xsd : Framework XML Schema files
- runtime
- component : Components to deploy
- example : An example application
- tools : Framework administration and maintenance tools
- webroot : Root Screen and supporting content
- conf : Configuration files separated by dev, staging, prod, etc
- db : Database files for Derby, etc will go here
- lib : JAR files to add to classpath
- log : Log files will go here
- mantle : The Mantle root can go here, with components under it
- template : General Templates
- tmp : Temporary files