我想执行一个副本并获得两个不同的对象,以便我可以在不影响原始文件的情况下处理副本.
我有这个代码(groovy 2.0.5):
def a = [[1,5,2,1,1], ["one", "five", "two", "one", "one"]]
def b = a
b.add([6,6,6,6,6,6])
println a
println b
Run Code Online (Sandbox Code Playgroud)
产生:
[[1, 5, 2, 1, 1], [one, five, two, one, one], [6, 6, 6, 6, 6, 6]]
[[1, 5, 2, 1, 1], [one, five, two, one, one], [6, 6, 6, 6, 6, 6]]
Run Code Online (Sandbox Code Playgroud)
看起来像b和a实际上是同一个对象
我可以用这种方式解决它:
def a = [[1,5,2,1,1], ["one", "five", "two", "one", "one"]]
def b = []
a.each {
b.add(it)
}
b.add([6,6,6,6,6])
println a
println b
Run Code Online (Sandbox Code Playgroud)
产生我想要的结果:
[[1, …Run Code Online (Sandbox Code Playgroud) 我有一个Grails 2.2.3应用程序使用此配置连接到mysql数据库:
production {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost/database?autoReconnect=true"
pooled = true
properties {
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
maxWait = 10000
}
}
}
Run Code Online (Sandbox Code Playgroud)
升级到Grails 2.3.0后,这已停止工作,在应用程序上周末不活动后,我收到此异常:
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 50,139,380 milliseconds ago. The last packet sent successfully to the server was 50,139,380 milliseconds ago. is longer than the server …Run Code Online (Sandbox Code Playgroud)