##Project fmu-core
##JIRA Link: Inera FMU
##Technology Stack (Languages, Tools & Frameworks):
- Language: Java 1.7
- IDE: IntelliJ (Recommended), STS, or NetBeans
- Production Database: MySql 5.6.4+
- Test Database: H2
- Code Management: Git
- Dependency & Build Management: Maven 3.0
- Database Migration Tool: Liquibase 3
- Logging Abstraction: SFL4J
- Logging Implementation: logback
- Unit Testing: JUnit 4 — The de-facto standard for unit testing Java applications.
- Persistence (Data Access): JPA, Hibernate 4 (One of the most popular JPA implementations.), Spring Data JPA (Makes it easy to easily implement JPA based repositories), Spring ORMs (Core ORM support from the Spring Framework)
- BPM: Activiti 5.15
- Mocking: Mockito
- Application Server: Tomcat
- Object to JSON Mapping: Jackson
- Date Time Utility: Joda-Time
- Assertion Library: Hamcrest - A library of matcher objects (also known as constraints or predicates) allowing assertThat style JUnit assertions.
- Integration Test Support: Spring Test — integration test support for Spring applications.
- JDBC Connection Pool: HikariCP - HikariCP is a high performance JDBC connection pool.
- Properties file format: YAML
- @ToString: lombok
- AOP: Spring AOP Logging, Transactions,
- Profiles: Maven & Spring Profiles
- Scripting Language: Groovy
###Code Base
- Download and install Git.
- Right the folder which you want to be the home for the codebase, and choose Git Bash.(For integration of IntelliJ with Git, refer to the section below Setting Up the Environment->IntelliJ point 4 onward)
- Paste
git clone https://github.com/rasheedamir/fmu-core.git
- Give the password when prompted.
###Project Structure
##Setting up the Environment:
###- JAVA
###- Maven
###- IntelliJ
- Install an IDE. Here we will assume the usage of IntelliJ. Download IntelliJ IDEA. Ultimate version needs to be bought. Install IntelliJ.
- Configure Groovy in IntelliJ.
- At startup after IntelliJ installation, add support for the plugin of Grails.
- Otherwise, you can later change it from File -> Settings. Then choose plugins, and check Grails.
- Enable Git in IntelliJ, as mentioned in the step above.
- After that, go to Project->Settings, under Version Control, click Git. On the right hand panel, you need to give the address to the git executable, named git.exe, present in
.../Git/bin/
. - For the ssh drop down right below the executable field, its preferable to choose "Built In".
- For more information on this issue, refer to jetbrains website.
- For projects being developed on cross-platform operatins systems, windows uses CRLF line endings(a format) and Linux, OS X use LF line ending format. If not taken care of these line endings will be changed from one format to the other, causing in merge conflicts. There are 2 possible solutions:
- If using from Git, you need to change the 'core.autocrlf' property in the Git config to 'true'(for Windows) or to 'input' in case of Linux.
- From IntelliJ itself wth Git integrated, you need to place an xml file here:
.IntelliJIdea12\config\codestyles\Default _1_.xml
, which contains policies for the commiting.
More info on this topic can be found here
###- Eclipse (for Activiti Diagram Only) In addition to installing the maven package and the eclipse package, and all their dependencies, you need to install the m2e extension. The best way to do this is using the Eclipse Marketplace, but the marketplace is not installed by default in the Ubuntu package.
- Open Eclipse, go to Help -> Install New Software...
- Select All Available Sites in the Work with dropdown menu.
- Wait for the list of software to populate; sometimes it takes a very long time.
- Expand the General Purpose Tools group, and tick Marketplace Client.
- Click Next, and again, accept the terms and conditions and click Finish.
This will install the marketplace. You will need to restart Eclipse for the change to take effect.
- Open Eclipse, go to Help -> Eclipse Marketplace...
- Wait for it to finish loading.
- Enter "maven" in the search box and press return.
- Click the Install button next to Maven Integration for Eclipse by Eclipse.org (NB: there is a similar item above called "Maven Integration for Eclipse WTP" by Red Hat, Inc; this is not the correct one).
Again, you will need to restart Eclipse for this to take effect.
The following installation instructions are verified on Eclipse Juno.
Go to Help -> Install New Software. In the following panel, click on Add button and fill in the following fields:
Name: Activiti BPMN 2.0 designer Location: http://activiti.org/designer/update/
Make sure the "Contact all updates sites.." checkbox is checked, because all the necessary plugins will then be downloaded by Eclipse.
###- Git
- Download latest version of git
- msgit for windows
sudo apt-get install git-core
- for ubuntu/debian
- Select point 3 Run git and included unix tools from the windows command prompt, when needed. Path will be updated during installation.
- Open console and check
git --version
. The result should be likegit version 1.9.0.msysgit.0
. - If git installation successful, generate ssh keys and add it to Bitbucket account, follow to the official guide.
###- MySql
- Window users:
- Download latest version of MySql community server
- Run
.exe
or.msi
file and follow the instructions. - Select Developer default.
- Specify password for root user.
Follow this guide, if there is any questions.
- Ubuntu/Debian users:
sudo apt-get install mysql-server mysql-client
###- Database Setup
- Create a new database named
---
. - MySql Settings:
- username =
----
, - password =
----
, - host =
----
, - port =
3306
.
- username =
- Open the terminal and type
mysql -u root -p
- Enter the password when prompted
---
- Create database
create database ---
(The output should be "Query OK, 1 row affected")
DROP DATABASE fmu
;
CREATE DATABASE fmu
CHARACTER SET utf8 COLLATE utf8_general_ci;
https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
###Using Codebase
###fmu-core on IntelliJ
###Debug on Intellij
-
Open Run -> Edit configurations
-
Click green
+
and choose remote -
Set name e.g. debug,
Use following settings:
- Transport:
Socket
- Debugger mode:
Attach
- Host:
localhost
- Port:
5005
- it's default grails debug port
- Transport:
##Logs
- Application logs can be found here: fmu-core/logs
##TroubleShooting
- There may be errors while running the application
##Generating Liquibase ChangeLog
mvn resources:resources liquibase:diff -Pprod
##Running/Debugging the Application
###Add 'resources' directory to classpath in IntelliJ 13
- Click on the Project view or unhide it by clicking on the "1: Project" button on the left border of the window or by pressing Alt + 1
- Find your project or sub-module and click on it to highlight it, then press F4, or right click and choose "Open Module Settings"
- Click on the dependencies tab
- Click the "+" button on the right and select "Jars or directories..."
- Find your path and click OK
- In the dialog with "Choose Categories of Selected File", choose classes (even if it's properties), press OK and OK again
You can now run your application and it will have the selected path in the classpath.
###As a "main" Java class From your IDE, right-click on the "Application" class at the root of your Java package hierarchy, and run it directly. You should also be able to debug it as easily.
The application will be available on http://localhost:8080.
###As a Maven project You can launch the Java server with Maven:
mvn spring-boot:run -Pprod The application will be available on http://localhost:9090
If you want more information on using Maven, please go to http://maven.apache.org
##Profiles
fmu-core comes with two "profiles":
- "dev" for development: it focuses on ease of development and productivity
- "prod" for production: it focuses on performance and scalability
Those profiles come in two different configurations:
- The Maven profiles are used at build time. For example mvn -Pprod package will package a production application.
- The Spring profiles work a run time. Some Spring beans will behave differently, depending on the profile.
Spring profiles are set by Maven, so we have a consistency between the two methods: of course, we have a "prod" profile on Maven and Spring at the same time.
###dev In default mode, fmu-core will use the "dev" profile If you run the application without Maven, launch the "Application" class (you can probably run it easily from your IDE by right-clicking on it).
If you run the application with Maven, run mvn -Pdev spring-boot:run
###prod In production, fmu-core has to run with the "prod" profile Use Maven to build the application with the "prod" profile: mvn -Pprod spring-boot:run
##Plugins
###EditorConfig EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. Read more here
mvn resources:resources liquibase:update -P<profile_name> Invoking the resources is necessary in order to have the liquibase.properties placeholders filtered. The -P option tells Maven the profile to use and thus the set of values (from the filter properties file) to use for filtering.
##Testing
###Unit Tests We use the Surefire Maven plugin to run our unit tests. Run following command to run unit tests:
mvn clean test
###Integration Tests The Failsafe Maven plugin is used to execute our integration tests. Run following command to run integration tests:
mvn clean verify -P integration-test