2015年6月27日 星期六

Maven Note - Basic

I have study this project manage tool, Maven, for a while. But, I still feel confused for this tool. I used Ant for my previous job. This is an easy tool to manage project. But, it does not have the dependency management. So, we still need to learn it. Actually, if you are java coder, you should learn it for its basic mech anism. Other program languages also have their own project manage tool, but this is not our main goal. So, I make a list which your should learn.

Installation
The Concept of Maven
Create a project
Know about pom.xml



Installation


How to install maven, you can google. If you use mac, you can used Homebrew is a very great package manage tool.
brew install maven



The Concept of Maven


There are some good tutorials of Maven
Chinese-
http://www.codedata.com.tw/java/understanding-gradle-2-maven/
http://juvenshun.iteye.com/blog/213959
http://takeshi-experience.blogspot.tw/2011/12/java-mvc-sample-2-with-maven.html
English-
http://www.javacodegeeks.com/?s=maven

Using a simply way to explain, there are three life cycle clean, default, site.
clean life cycle - you should clean your previous building content, before you build new one.
build life cycle - build your project, and deploy it.
site life cycle - Analyze the project data.

There are many phases defined for each life cycle. You can read this
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference 

Each phase define its workflow and goal to execute.
goal is a maven plugin to execute the command, like compiler:compile.
compiler is the plugin name, and compile is the goal name.

You can also combine these three lifecycle, like mvn clean compile site. compile is a phase of default lifecycle.



Create a project


You can use command line to build a simple project, like

mvn archetype:generate -DgroupId=com.di.maven -DartifactId=hello-world -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false


Actually, you can also use Eclipse( or other IDE which support Maven) to build Maven Project.
There pictures are how to create a Maven project in Eclipse.








Know about pom.xml


This is a simple pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.di.maven</groupId>
  <artifactId>hello-world</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>hello-world</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Maven is a convention over configuration software design pattern.  This is why pom.xml file is so sample. We have a super pom.xml which config a lot of detail. So, we can start a sample project faster. But, it still confused for me. Actually, when you need to setup other configuration, you still need to figure out the correct way to config. This topic is still a problem for me. Anyway, let start it easier. In this pom.xml file, we only need to understand how to add the jar files which is needed for our project. You only add the dependency config to <dependencies>. It will auto download the jar files we need. This is also why we need to use Maven. Maven can solve the dependency hell in some situations. Otherwise, <scope> is mean the dependency will effect which s cenario will be used.

You also can search the dependency you need in
http://mvnrepository.com/

Further, there is an example which we had built before.
https://github.com/bpmabpma/JBossExmple/blob/master/springMvc/pom.xml

We can see a lot new Xml elements show up, such as <properties>, <dependencyManagement>,  <<build>, <plugin>, <profiles>. I think they are very important. But, in my present situation, I should build my project be my primary job. So, when I finish build the major part of coding. I should return Maven, and build the CI system based on Maven.

Moreover, if you really need to an expert of Maven. You should read this
http://maven.apache.org/guides/index.html




2015年6月23日 星期二

Create sample project(1) - Spring MVC + JBoss

Actually, this pototype is stole from somewhere...
Anyway, I think this a good way to start my work.
So, let start...

Later, maybe I will research why JBoss is a good AP Server Choice, and compare with other ap server(or http server). But, this is a huge work. I desire to build something first. Otherwise, the reasons why I prefer Spring MVC be my MVC framework. Maybe it is not the best choice, but on least it work perfect on Spring framework. Maybe I will also research MVC framework later.

Prepare

There are some stuffs, we need to download before starting development.
Eclipse Luna
JBoss EAP 6.4
Maven 3.3.3

Extra Config and Plugin

If we don't find the Maven Central,  we will need to setup the Maven repository url.
Preference->Maven->Archetypes->Add Remote Catalog...
Catalog File = http://repo.maven.apache.org/maven2/archetype-catalog.xml
Description = Maven Central

And, we can install the JBoss plugin on Eclipse(many feathers which we can use).

Import Maven Project

We can quickly import the sample project from the remote Maven repository.
This is one is our need.

Setup Server and Run

Use startup or Server Perspective


See the Result



Conclusion

I cut out a lot of details, just show the key point for my note. JBoss has its own default H2 database, so we can see some database applications. Next step, we will create our own database and JPA(implemented by Hibernate) config.

Github link

https://github.com/bpmabpma/JBossExmple




2015年6月18日 星期四

Build my own project - Blueprint

Strugling a long time, I have choose some frameworks and tools to build my own project. The majority reasons I choice are free and based on Java.

AP server - JBoss, the reason which I choice is it can easily be a distributed system. There are more advantages, but I am still learning. It is new for me.  It also have support JEE standard. Its main target is EJB support, but it also support web operation now. Otherwise, it can handle other JEE standard(I am still figuring it out now)

MVC - Spring MVC, there are the plenty of options on MVC framework to choice, such as Struct 2, Wicket, Tapestry, Play, etc.  So, why I take this one.

Front End - AngularJs or React, they are two frameworks which are very popular now. They can easy develop the code of front end. I am not farmiliar with them. But, I trust them can more efficiently develop on the front end.

ORM - Hibernate, because it is very suitable with JBoss. Mybatis is another option, but it is suitable for the old database scheme or more efficient requirement.

DB - Postgre and Mongo DB, one is RMDB, one is no-sql for the different purposes. Postgre is more like Oracle, so I chose. Mongo is more popular, so... . It has its own advantage, such as easy to use, flexible, etc. But, I have really do research on other options.

IDE - Eclipse

Project Management - Maven and Ant(if it is more convenient).

Monitor - Not know yet.

Testing Tool - Maybe TestNG or just Junit, not decide yet.

CI - Jenkins

SCM - git and github...

Hey, just a list, let start building.





2015年6月12日 星期五

The todo list of second half of 2015

I have a long time to write the my blog.
I want to change this blog target.
This blog still records my research of IT technology.
But, I will write the content by English.

I have found the new job on my career.
But, I still think the goal of my career.
Oversea, remote, contractual, and consultant are all acceptable.
Architect, free System Design, Startup are all the paths of future.
Anyway, I will take some time to think about it.
The new goal in my new company also must be thought.

The goal of my career is not an emergency issue.
Even it is changeable, but I still need to find it ASAP.
Then, I will work on it.

In the short term, I will take my time to study the architect.
Then, I will create a project on the AWS.
Practice is an easy way to implement dream.

I have some skills and tools on Backend(Java).
I not very good on the front end, but still have a certain knowledge and experience.
So, I will work on some old skill, like Java, and old tool, like Eclipse.
But, I will study the new tools which I am not familiar with.

Following are the list of my study list.
Maven - This is a project manage tool.
JBoss - This is a middleware application server. Its main target is manage EJB. It is                         work on my new job.
Angular or React - There are two modern JS framework. I will choice one( or both) to               implement the front end.
MCV - Choice a Java MVC framework? I still not sure to use java be my backend
              language. There are  some frameworks, such as Spring MVC, Jersey(Restful).
MEAN - This is new architecture for web site design. Mongo, Express, Augular,
              Node.js.
 Memcached or Redis - There are two memory cach tool.
AP Server - Tomcat, JBoss, Webphere, Nginix
DB - Mongo DB
MQ - Ative MQ
Spring 4 & Java 8 - Java new tech.
Design Pattern
Refactoring
SA - Diagram

I have some skills and tools, bellowing
Eclipse, ant, Java7, JQury(not very good), html, javascript(not good), Tomcat, Wicket, Camel, linux(basic)...

Somehow I think I do not have so much time to learn or review all stuff...
Anyway, create a easy sample project first...