Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit e2d0e47

Browse files
committed
Polish sample to only use the framework
1 parent 272b94e commit e2d0e47

File tree

5 files changed

+36
-60
lines changed

5 files changed

+36
-60
lines changed

SPR-14719/pom.xml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>com.example</groupId>
@@ -11,59 +11,39 @@
1111
<name>refresh</name>
1212
<description>Demo project for Spring Boot</description>
1313

14-
<parent>
15-
<groupId>org.springframework.boot</groupId>
16-
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.4.0.RELEASE</version>
18-
<relativePath /> <!-- lookup parent from repository -->
19-
</parent>
20-
2114
<properties>
2215
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2316
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24-
<java.version>1.8</java.version>
17+
<maven.compiler.source>1.8</maven.compiler.source>
18+
<maven.compiler.target>1.8</maven.compiler.target>
2519
</properties>
2620

2721
<dependencies>
2822
<dependency>
29-
<groupId>org.springframework.boot</groupId>
30-
<artifactId>spring-boot-starter-actuator</artifactId>
23+
<groupId>org.springframework</groupId>
24+
<artifactId>spring-context</artifactId>
25+
<version>4.0.0.RELEASE</version>
3126
</dependency>
3227
<dependency>
33-
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-starter-web</artifactId>
28+
<groupId>org.springframework</groupId>
29+
<artifactId>spring-beans</artifactId>
30+
<version>4.0.0.RELEASE</version>
3531
</dependency>
3632
<dependency>
3733
<groupId>org.codehaus.groovy</groupId>
3834
<artifactId>groovy</artifactId>
3935
</dependency>
40-
<dependency>
41-
<groupId>org.springframework.boot</groupId>
42-
<artifactId>spring-boot-starter-test</artifactId>
43-
<scope>test</scope>
44-
</dependency>
4536
</dependencies>
4637

4738
<dependencyManagement>
4839
<dependencies>
4940
<dependency>
50-
<groupId>org.springframework.cloud</groupId>
51-
<artifactId>spring-cloud-dependencies</artifactId>
52-
<version>Brixton.SR5</version>
53-
<type>pom</type>
54-
<scope>import</scope>
41+
<groupId>org.codehaus.groovy</groupId>
42+
<artifactId>groovy</artifactId>
43+
<version>2.4.7</version>
5544
</dependency>
5645
</dependencies>
5746
</dependencyManagement>
5847

59-
<build>
60-
<plugins>
61-
<plugin>
62-
<groupId>org.springframework.boot</groupId>
63-
<artifactId>spring-boot-maven-plugin</artifactId>
64-
</plugin>
65-
</plugins>
66-
</build>
67-
6848

6949
</project>
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
package com.example;
22

3-
import org.springframework.boot.SpringApplication;
4-
import org.springframework.boot.autoconfigure.SpringBootApplication;
3+
import java.io.IOException;
4+
5+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
6+
import org.springframework.context.annotation.Configuration;
57
import org.springframework.context.annotation.ImportResource;
68

7-
@SpringBootApplication
9+
@Configuration
810
@ImportResource("classpath:/beans.xml")
911
public class RefreshApplication {
1012

11-
public static void main(String[] args) {
12-
SpringApplication.run(RefreshApplication.class, args);
13+
public static void main(String[] args) throws IOException {
14+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RefreshApplication.class);
15+
Object foo = context.getBean("foo");
16+
System.out.println(foo);
17+
System.out.println("Make so change to the script and press enter to continue");
18+
System.in.read();
19+
System.out.println(foo);
20+
1321
}
22+
1423
}

SPR-14719/src/main/resources/beans.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
55
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd">
66

7-
<lang:groovy proxy-target-class="true" refresh-check-delay="1000"
7+
<lang:groovy proxy-target-class="true" refresh-check-delay="1000" id="foo"
88
script-source="file:src/main/resources/controller.groovy" />
99

1010
</beans>
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import org.springframework.web.bind.annotation.RequestMapping
2-
import org.springframework.web.bind.annotation.RestController
1+
import org.springframework.cache.annotation.Cacheable
32

4-
@RestController
53
class Sample {
6-
7-
@RequestMapping("/")
8-
String home() {
4+
5+
@Cacheable("foo")
6+
String test() {
97
"Hello World"
108
}
11-
9+
10+
String toString() {
11+
test()
12+
}
13+
1214
}

SPR-14719/src/test/java/com/example/RefreshApplicationTests.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)