idea导入grails项目想选这个选项需要配置啥
1个回答
展开全部
1.安装grails
下载grails,然后配置:
GRAILS_HOME=”D:/JavaDev/grails”
path追加:%GRAILS_HOME%/bin
2.创建grails项目
3.配置数据源
打开conf/DataSource.groovy
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=false
validationQuery="SELECT 1"
jdbcInterceptors="ConnectionState"
}
}
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546
4.引入数据库驱动包
lib下添加mysql-connector-java-5.1.32.jar
用命令refresh-dependencies添加到依赖
5.新建Domain类。
两种方式:(1)通过命令:create-domain-class Book(2)右键-〉New-〉Domain Class
Book代码如下:
package hellograils
class Book {
String title
String content
static constraints = {
}
}12345678
6.创建controller和views:两种方式
(1)打Book类,点击图标上面的Controller 和Views 就可以产生代码了
(2)命令grails generate-all hellograils.Book
grails会自动创建Controller(会自动生成增、删、改、查的相关方法)和View(会自动生成增、删、改、查的相关页面)
下载grails,然后配置:
GRAILS_HOME=”D:/JavaDev/grails”
path追加:%GRAILS_HOME%/bin
2.创建grails项目
3.配置数据源
打开conf/DataSource.groovy
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.58.11:3306/grailsdb?useUnicode=true&characterEncoding=UTF-8"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=false
validationQuery="SELECT 1"
jdbcInterceptors="ConnectionState"
}
}
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546
4.引入数据库驱动包
lib下添加mysql-connector-java-5.1.32.jar
用命令refresh-dependencies添加到依赖
5.新建Domain类。
两种方式:(1)通过命令:create-domain-class Book(2)右键-〉New-〉Domain Class
Book代码如下:
package hellograils
class Book {
String title
String content
static constraints = {
}
}12345678
6.创建controller和views:两种方式
(1)打Book类,点击图标上面的Controller 和Views 就可以产生代码了
(2)命令grails generate-all hellograils.Book
grails会自动创建Controller(会自动生成增、删、改、查的相关方法)和View(会自动生成增、删、改、查的相关页面)
追问
我想导入一个grails项目而不是创建一个项目,但是那个选项是灰色的。应该是需要在哪里配置一下的吧
浙江启扬智能科技有限公司
2023-06-12 广告
2023-06-12 广告
Linux 嵌入式系统中,USB 启动模式能够烧写 ARM 的 uboot 的原因主要有以下几个方面:1. USB 启动模式相对于传统的 BIOS 启动模式来说,具有更高的兼容性和灵活性,可以支持更多的硬件设备和操作系统。2. USB 启动...
点击进入详情页
本回答由浙江启扬智能科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询