mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
25 lines
361 B
Groovy
25 lines
361 B
Groovy
package org.test
|
|
|
|
import static org.springframework.boot.groovy.GroovyTemplate.*
|
|
|
|
@Component
|
|
class Example implements CommandLineRunner {
|
|
|
|
@Autowired
|
|
private MyService myService
|
|
|
|
@Override
|
|
void run(String... args) {
|
|
print template("test.txt", ["message":myService.sayWorld()])
|
|
}
|
|
}
|
|
|
|
|
|
@Service
|
|
class MyService {
|
|
|
|
String sayWorld() {
|
|
return "World"
|
|
}
|
|
}
|