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...







2015年1月10日 星期六

[Maven]基本概念

2014一下子就過去了
轉眼間就2015了…
也一陣子沒有寫Blog了
一直想整理一下常用的framework和開發工具
不過大部分的時間都在混水摸魚
希望2015能完成這個目標丫

2015的首po
就從一個很基礎的開發工具開始
Maven


2014年11月4日 星期二

IntellijIDEA學習整理-快捷鍵

前言
最近研究了一套新的IDE Intellij IDEA
主要是根據研究的資料來整理而已,並沒有針對整個對應表進行整理
這一篇先整理一下,他一些好用的快捷鍵
先主要分成幾個部分好了
第一個部分是工具視窗的部分
第二個部分是程式瀏覽和查詢的部分
第三個部分是純文字編輯的部分
第四個部分是自動化的部分
第五個部分寫一些特殊的設計的概念
另外,還有些不知道在幹嘛的,先記著

2014年8月12日 星期二

Shell Scripts和程式執行方式

好久沒寫Blogger,因為ipad太好玩了,打混了一陣子
不過這次主要要寫在linux上遇到的問題
就是執行shell script的方式,主要是要執行一段script來export一些路徑
但是卻一直沒有成功,原來是因為執行方式錯誤造成。

shell script的執行方式主要有三種
./your_script.sh
sh your_script.sh
source your_script.sh

使用./sh的方式都會呼叫子程序的方式來執行
source是在當前的程序執行
所以使用source來執行script就可以解決我的問題了。

如果是希望在登入的時候,就將路徑設定好
就需要到家目錄($HOME)的 .profile 或 .bashrc 設定檔加上
要export的路徑

另一個問題是在執行程式時遇到的
寫了一隻常駐程式,在compile完之後
可以使用
./your_app
的方式來執行

但我執行完後,想要把連線關閉(我在這裏使用ssh進行連線)
其常駐程式也會跟著關閉

最直接的方式是使用at的指令(at為一次執行,cron是周期執行)
新增工作排程的方式
不過他有限定特定使用者才能使用
所以用另一個指令nohup的方式來執行會更好
執行方式
nohup your_app &

參考資料:
http://linux.vbird.org/linux_basic/0340bashshell-scripts.php
http://linux.vbird.org/linux_basic/0430cron.php#whatiscron_type
http://linux.vbird.org/linux_basic/0440processcontrol.php