How to add a custom page into Spring Roo

First of all edit your {project_root}/src/main/webapp/WEB-INF/spring/webmvc-config.xml and add new mvc:view-controller definition for your new page. Something like:

<mvc:view-controller path="/custompage" />

Then open {project_root}/src/main/webapp/WEB-INF/views/views.xml and add the following definition:

  <definition extends="public" name="custompage">
    <put-attribute name="body" value="/WEB-INF/views/custompage.jspx"/>
  </definition>

And add your custompage.jspx to the {project_root}/src/main/webapp/WEB-INF/views/ folder.

And then edit {project_root}/src/main/webapp/WEB-INF/views/menu.jspx and new menu:item with url="/custompage".

I think it should work.

 

I made some mistakes and it took me long time to figure it out.

What it does is add “/WEB-INF/views/custompage.jspx" this page to the path /custompage

 

Import and configure the roo project from Bitbucket

Yahoooo! Finally, after one day’s work, I successfully imported our group project from Bitbucket to my computer and configured to run on the tomcat.

Well, it’s actually pretty simple.

Project–>Import from GIT-> type in the http link which links to our group project’s repository.

since other members have installed some modules to the project, the dependencies are listed in pom.xml.

the good thing is if you go to the imported project, go to roo shell, and do perform eclipse, it will auto download everything: those jar files you needed for your project.

then refresh the project in your IDE, and run it with maven!

oh, you have to configure the database.property file in order to match with the database info.

that’s it, done!!

Connect to MYSQL in Spring Roo

First you need to install MYSQL, then setup the database e.g “jarvis”

then run the following command

jpa setup –provider HIBERNATE –database mysql

then you need to edit the file at src/main/resources/meta-inf/spring/database.properties as follows

#Updated at Sat Sep 15 19:31:58 EST 2012
#Sat Sep 15 19:31:58 EST 2012
database.driverClassName=com.mysql.jdbc.Driver
database.url=jdbc\:mysql\://localhost\:3306/jarvis
database.username=root
database.password=basser

properties list –name database.properties –path String_config_root

this command shows you the configuration.

After you have done this, you can add in the entities

and then do the mvc setup:

web mvc setup

web mvc all –package ~.web

Now if you run the project, it will give the error that the driver is not found

you have to run “perform eclipse” command,

this is a magic command that it will look at the dependencies from the .pom file and download all the libraries(jars) that are required,

it will store the libraries at the local repository, in my case it’s at “C:\Users\Jackie\.m2\repository\”

Remember don’t stop the perform eclipse half way like I did, or you will have to delete the files and do the command again, it took me ages to figure it out why the files are there but it just doesn’t work.

in the persistence.xml, there is a <property name=”hibernate.hbm2ddl.auto” value=”create”/>, this decides what will happen to the table each time you run it.