Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit e075294

Browse files
committed
spring run command removed in 3.x, convert app.groovy to standalone groovy script
1 parent 737a353 commit e075294

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ To run Spring Boot Script App
1515
```shell
1616
cd sample-apps/gsp/script
1717
sdk env
18-
spring run app.groovy
18+
groovy -Dgroovy.grape.report.downloads=true app.groovy
1919
```

grails-gsp-spring-boot/src/main/java/grails/gsp/boot/GspAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ protected static class GspTemplateEngineAutoConfiguration extends AbstractGspCon
113113

114114
@Bean
115115
@ConditionalOnMissingBean(name="groovyPagesTemplateEngine")
116-
GroovyPagesTemplateEngine groovyPagesTemplateEngine(TagLibraryResolver tagLibraryResolver, TagLibraryLookup tagLibraryLookup) {
116+
GroovyPagesTemplateEngine groovyPagesTemplateEngine(TagLibraryResolver tagLibraryResolver, TagLibraryLookup tagLibraryLookup, GroovyPagesTemplateRenderer groovyPagesTemplateRenderer) {
117117
GroovyPagesTemplateEngine templateEngine = new GroovyPagesTemplateEngine();
118118
templateEngine.setReloadEnabled(gspReloadingEnabled);
119119
templateEngine.setJspTagLibraryResolver(tagLibraryResolver);
120120
templateEngine.setTagLibraryLookup(tagLibraryLookup);
121+
groovyPagesTemplateRenderer.setGroovyPagesTemplateEngine(templateEngine);
121122
return templateEngine;
122123
}
123124

sample-apps/gsp/script/.sdkmanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
java=17.0.12-librca
2-
groovy=4.0.24
2+
groovy=4.0.23
33
springboot=3.3.5

sample-apps/gsp/script/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Use the following command with Spring Boot CLI 2.x
1+
Use the following command with Groovy CLI 4.x
22

33
```shell
4-
spring run app.groovy
4+
sdk env
5+
groovy -Dgroovy.grape.report.downloads=true app.groovy
56
```

sample-apps/gsp/script/app.groovy

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
package demo
2+
13
@GrabResolver(name='grails-repo', root='https://repo.grails.org/grails/core/')
24
@Grab("org.grails:grails-gsp-spring-boot:7.0.0-SNAPSHOT")
5+
@Grab("org.grails:grails-plugin-controllers:7.0.0-SNAPSHOT")
6+
// if you need to clear snapshots, they are saved to ~/.groovy/grapes
7+
8+
import org.springframework.boot.autoconfigure.SpringBootApplication
9+
import org.springframework.boot.SpringApplication
10+
import org.springframework.web.bind.annotation.RequestMapping
11+
import org.springframework.web.bind.annotation.RestController
12+
import org.springframework.stereotype.Component
13+
import org.springframework.context.annotation.Bean
14+
import grails.gsp.boot.GspAutoConfiguration
15+
import org.springframework.boot.autoconfigure.ImportAutoConfiguration
316

417
import grails.gsp.TagLib
518
import org.springframework.web.servlet.ModelAndView
@@ -10,7 +23,7 @@ class GspController {
1023
@RequestMapping("/")
1124
ModelAndView home() {
1225
new ModelAndView('index', 'name', 'world')
13-
}
26+
}
1427
}
1528

1629
@Component
@@ -19,4 +32,15 @@ class FormatTagLib {
1932
def dateFormat = { attrs, body ->
2033
out << new SimpleDateFormat(attrs.format).format(attrs.date)
2134
}
22-
}
35+
}
36+
37+
@SpringBootApplication
38+
@ImportAutoConfiguration(GspAutoConfiguration.class)
39+
class Application {
40+
@Bean GspController rspController() { new GspController() }
41+
@Bean FormatTagLib formatTagLib() { new FormatTagLib() }
42+
}
43+
44+
System.setProperty("org.springframework.boot.logging.LoggingSystem", "none")
45+
46+
SpringApplication.run(Application)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
spring.gsp.templateRoots=classpath:/templates
22
spring.main.allow-circular-references=true
3-
grails.views.gsp.sitemesh.preprocess=false
43
sitemesh.decorator.default=main

0 commit comments

Comments
 (0)