Added JDBC and @Transactional support to Groovy CLI
* @EnableTransactionManagement triggers spring-tx imports * Field or method of type JdbcTemplate or NamedParameterJdbcTemplate of DataSource triggers spring-jdbc imports
This commit is contained in:
18
spring-boot-cli/samples/tx.groovy
Normal file
18
spring-boot-cli/samples/tx.groovy
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.test
|
||||
|
||||
@Grab("org.hsqldb:hsqldb:2.2.9")
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
class Example implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
JdbcTemplate jdbcTemplate
|
||||
|
||||
@Transactional
|
||||
void run(String... args) {
|
||||
println "Foo count=" + jdbcTemplate.queryForObject("SELECT COUNT(*) from FOO", Integer)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user