Wednesday, April 1, 2009

Appfuse 2, Intro with Maven

I create new project using appfuse2, the main difference with appfuse1.9 is now we use maven rather than ant to build for example. The tutorial is already clear in appfuse site. But I will rewrite it in my own words.

1. Jdk and tomcat for the simple one.
2. Install maven, just download it, or apt-get it when if using ubuntu as me
3. Install mySql, I want to make the simple project one, so I use mySql because it is the default of appfuse, same as maven we can download it or apt-get from repository.
4. From the terminal type: mvn archetype:create and choose the framework, I choose the Spring basic from the options, actually I already try to make tapestry project, but fail in the midle. Here is the full syntax to create the project with basic SpringMVC:

mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject

5. We must connect with internet incase we use the maven repository from internet, and it will download bunch of things from repository. And it should end with something like build successfully. and a folder named myproject is created.

6. Because it will be easier when uding IDE, so we can do as follow:
- From eclipse, create new java project
- Choose the radio: create project from existing source and browse it into myproject folder
- name it myproject

7. From terminal enter into myproject folder and type mvn or "mvn appfuse:full-source" for getting all the resources. if we only type mvn we will refer sources or classes into the repository, we cannot see or modify the code. This stage needs lot of times because download many things, but we can stop it and continuing next time because once it download, it is not need to download again. I remember actually I start with appfuse2 few weeks ago and meet some fails, and yesterday I continue my work.

And AFAIR we will meet some errors with the default source code, first we need to copy junit jar and refer it. I do this with copying junit.jar and add library to it, we must know it when using eclipse, so there are no error sign in our source explorer.

And we must change the password of the database in file jdbc.properties:
jdbc.password=ourPassword
hibernate.connection.password=ourPassword

and in the file pom.xml:
<jdbc.password>ourPassword</jdbc.password>

also in the pom.xml if we want to use our installed tomcat we comment this statement:
<zipUrlInstaller>
<url>${cargo.container.url}</url>
<installDir>${installDir}</installDir>
</zipUrlInstaller>

8. Type mvn jetty:run-war and it also start tomcat, so we can see our application in http://localhost:8080

1 comment:

JesperBlog said...

when commenting this part:
<zipUrlInstaller>

we also uncomment a line above those code:
<home>${cargo.container.home}</home>

that mean we use our installed application server