Java Spring Roo: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
== Installation == | |||
== First Application == | |||
== Create application from Database == | == Create application from Database == | ||
# Assuming Roo is installed | # Assuming Roo is installed | ||
# Validate with the roo addon manager if Mysql is already install org.springframework.roo.wrapping.mysql | # Validate with the roo addon manager if Mysql is already install org.springframework.roo.wrapping.mysql | ||
# | # You may have to copy mysq.coonector.jar directly into the folder bundle in the roo installation directory | ||
=== Install Mysql Driver === | |||
<pre>addon search mysql</pre> | |||
<pre> addon install id 01</pre> | |||
* If it goes wrong | |||
<pre>osgi obr url add --url http://spring-roo-repository.springsource.org/repository.xml | |||
osgi obr deploy --bundleSymbolicName org.springframework.roo.wrapping.mysql-jdbc </pre> | |||
* If it goes very wrong | |||
Copy mysql-connect.jar into bundle directory of the root installation repository | |||
=== Create project === | |||
<pre>project --topLevelPackage com.objclt.roo.sample</pre> | <pre>project --topLevelPackage com.objclt.roo.sample</pre> | ||
=== Create Database Connection === | |||
* Create persistence.xml and database.properties | |||
<pre>persistence setup --provider HIBERNATE --database MYSQL --databaseName databaseName --hostName hostname --userName username --password password</pre> | <pre>persistence setup --provider HIBERNATE --database MYSQL --databaseName databaseName --hostName hostname --userName username --password password</pre> | ||
=== Validate database.properties === | |||
<pre>jdbc.driverClassName=com.mysql.jdbc.Driver | <pre>jdbc.driverClassName=com.mysql.jdbc.Driver | ||
jdbc.url=jdbc\:mysql\://localhost\:3306/Database_Name | jdbc.url=jdbc\:mysql\://localhost\:3306/Database_Name | ||
jdbc.usernameDatabase_User | jdbc.usernameDatabase_User | ||
jdbc.password=User_Password</pre> | jdbc.password=User_Password</pre> | ||
=== Validate persistence.xml === | |||
* Si operation is not mandatory as is will be replaced when generating entities from database | |||
* Replace create by validate inside persistence.xml to disable the auto database creation | |||
<pre> | <pre> | ||
"Before" | "Before" | ||
Line 19: | Line 39: | ||
property name="hibernate.hbm2ddl.auto" value="validate" | property name="hibernate.hbm2ddl.auto" value="validate" | ||
</pre> | </pre> | ||
=== Test Database Connection === | |||
<pre>database introspect --schema DatabaseSchema</pre> | <pre>database introspect --schema DatabaseSchema</pre> | ||
=== Reverse engineering of the database === | |||
<pre>database reverse engineer --schema DataBaseShema --package com.objclt.roo.sample</pre> | <pre>database reverse engineer --schema DataBaseShema --package com.objclt.roo.sample</pre> | ||
===Configure Web presentation Layer=== | |||
<pre>web mvc setup</pre> | |||
=== | === Generate Controller === | ||
<pre> | <pre>web mvc all --package ~.web</pre> | ||
Revision as of 18:16, 1 December 2014
Installation
First Application
Create application from Database
- Assuming Roo is installed
- Validate with the roo addon manager if Mysql is already install org.springframework.roo.wrapping.mysql
- You may have to copy mysq.coonector.jar directly into the folder bundle in the roo installation directory
Install Mysql Driver
addon search mysql
addon install id 01
- If it goes wrong
osgi obr url add --url http://spring-roo-repository.springsource.org/repository.xml osgi obr deploy --bundleSymbolicName org.springframework.roo.wrapping.mysql-jdbc
- If it goes very wrong
Copy mysql-connect.jar into bundle directory of the root installation repository
Create project
project --topLevelPackage com.objclt.roo.sample
Create Database Connection
- Create persistence.xml and database.properties
persistence setup --provider HIBERNATE --database MYSQL --databaseName databaseName --hostName hostname --userName username --password password
Validate database.properties
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc\:mysql\://localhost\:3306/Database_Name jdbc.usernameDatabase_User jdbc.password=User_Password
Validate persistence.xml
- Si operation is not mandatory as is will be replaced when generating entities from database
- Replace create by validate inside persistence.xml to disable the auto database creation
"Before" property name="hibernate.hbm2ddl.auto" value="create" "After" property name="hibernate.hbm2ddl.auto" value="validate"
Test Database Connection
database introspect --schema DatabaseSchema
Reverse engineering of the database
database reverse engineer --schema DataBaseShema --package com.objclt.roo.sample
Configure Web presentation Layer
web mvc setup
Generate Controller
web mvc all --package ~.web