spring roo反向工程
1、创建spring roo工程
2、在数据库中创建数据库feedback_schema,再创建几张表
3、创建连接数据库
persistence setup --provider HIBERNATE --database MYSQL --databaseName feedback_schema --userName root --password 123456
4、执行反向工程,即根据数据库表生成相应的.aj文件,如果是第一次执行的话,可能会提示JDBC driver not available for ‘com.mysql.jdbc.Driver',如下
roo> database reverse engineer --schema feedback_schema --package ~.domain
Searching 'com.mysql.jdbc.Driver' on installed repositories
1 matches found with 'com.mysql.jdbc.Driver' on installed repositories
ID BUNDLE SYMBOLIC NAME DESCRIPTION
--------------------------------------------------------------------------------
01 org.springframework.roo.wrapping.mysql-connector-java Spring Roo - Wrapping - mysql-connector-java
--------------------------------------------------------------------------------
[HINT] use 'addon info bundle --bundleSymbolicName' to see details about a search result
[HINT] use 'addon install bundle --bundleSymbolicName' to install a specific add-on version
Located add-on that may offer this JDBC driver
JDBC driver not available for 'com.mysql.jdbc.Driver'
5、根据提示安装org.springframework.roo.wrapping.mysql-connector-java,执行命令如下
roo> addon info bundle --bundleSymbolicName org.springframework.roo.wrapping.mysql-connector-java
Name.........: Spring Roo - Wrapping - mysql-connector-java
BSN..........: org.springframework.roo.wrapping.mysql-connector-java
Version......: 5.1.18.0002
JAR Size.....: 797006 bytes
JAR URL......: http://repo.spring.io/spring-roo/org/springframework/roo/wrapping
/org.springframework.roo.wrapping.mysql-connector-java/5.1.18.000
2/org.springframework.roo.wrapping.mysql-connector-java-5.1.18.00
02.jar
Commands.....: com.mysql.jdbc.Driver,
roo> addon install bundle --bundleSymbolicName org.springframework.roo.wrapping.mysql-connector-java
Target resource(s):
-------------------
Spring Roo - Wrapping - mysql-connector-java (5.1.18.0002)
Deploying...
done.
roo> Starting org.springframework.roo.wrapping.mysql-connector-java; id: 85 ...
Started!
Searching 'com.mysql.jdbc.Driver' on installed repositories
1 matches found with 'com.mysql.jdbc.Driver' on installed repositories
ID BUNDLE SYMBOLIC NAME DESCRIPTION
--------------------------------------------------------------------------------
01 org.springframework.roo.wrapping.mysql-connector-java Spring Roo - Wrapping - mysql-connector-java
--------------------------------------------------------------------------------
[HINT] use 'addon info bundle --bundleSymbolicName' to see details about a search result
[HINT] use 'addon install bundle --bundleSymbolicName' to install a specific add-on version
Located add-on that may offer this JDBC driver
JDBC driver not available for 'com.mysql.jdbc.Driver'
5、根据提示安装org.springframework.roo.wrapping.mysql-connector-java,执行命令如下
roo> addon info bundle --bundleSymbolicName org.springframework.roo.wrapping.mysql-connector-java
Name.........: Spring Roo - Wrapping - mysql-connector-java
BSN..........: org.springframework.roo.wrapping.mysql-connector-java
Version......: 5.1.18.0002
JAR Size.....: 797006 bytes
JAR URL......: http://repo.spring.io/spring-roo/org/springframework/roo/wrapping
/org.springframework.roo.wrapping.mysql-connector-java/5.1.18.000
2/org.springframework.roo.wrapping.mysql-connector-java-5.1.18.00
02.jar
Commands.....: com.mysql.jdbc.Driver,
roo> addon install bundle --bundleSymbolicName org.springframework.roo.wrapping.mysql-connector-java
Target resource(s):
-------------------
Spring Roo - Wrapping - mysql-connector-java (5.1.18.0002)
Deploying...
done.
roo> Starting org.springframework.roo.wrapping.mysql-connector-java; id: 85 ...
Started!
6、安装完成之后,再次执行反向工程指令
database reverse engineer --schema feedback_schema --package ~.domain
7、增加controller
controller all --package ~.web
8、添加日志
logging setup --level INFO --package ALL_SPRING