Java Spring Roo
Jump to navigation
Jump to search
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
- Will generate the dbrx.xml
database introspect --schema DatabaseSchema
Reverse engineering of the database
Create Java Entity and AspectJ source
database reverse engineer --schema DataBaseShema --package com.objclt.roo.sample
Perform Junit Integration
test integration
Configure Web presentation Layer
web mvc setup
Generate Controller
web mvc all --package ~.web
Setup Security
- Create applicationContext-security.xml
security setup
Several Level of security
- Security by views Inside the applicationContext-seciruty.xml
<intercept-url pattern="/users/**" method="DELETE" access="hasRole('ROLE_ADMIN')" <intercept-url pattern="/roles/**" access="hasAnyRole('Administrator','role_display')" /> <intercept-url pattern="/roleslist/**" method="GET" access="isAuthenticated()" <intercept-url pattern="/**" access="permitAll"
- Inside a JSP page
xmlns:sec="http://www.springframework.org/security/tags <sec:authorize ifAllGranted="ROLE_ADMIN"> </sec:authorize> <sec:authorize ifAnyGranted="ROLE_ADMIN, ROLE_USER"> </sec:authorize> <sec:authorize ifNotGranted="ROLE_EXCLUDE"> </sec:authorize>
- Inside the java controller file
@RooWebScaffold(path = "processeses", formBackingObject = Processes.class,delete=false,update=false)
Email Setup
- Create email.properties
email sender setup --hostServer smtp.gmail.com --username YourEmailAddress --password YourPassword --port 587 --protocol SMTP
Add Finder Search
- Create finder for Entity : Concepts
finder add --class ~.model.Concepts
- List
finder list
Internationalization
- Create a message file per language messages_es.properties inside i18n folder
- Create a flag es.png inside images
- Update views/footer.jspx to add the new language
web mvc install language --code es
Integration into eclipse
perform eclipse