Skip to content

Commit de21b47

Browse files
authored
Merge pull request eugenp#4318 from eugenp/BAEL-1689
update spring boot ctx app, rename classes
2 parents ff9d4d4 + 6e2feb7 commit de21b47

File tree

15 files changed

+61
-59
lines changed

15 files changed

+61
-59
lines changed

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@
262262
<module>java-spi</module>
263263
<module>performance-tests</module>
264264
<module>twilio</module>
265-
<module>java-ee-8-security-api</module>
266-
<module>spring-webflux-amqp</module>
265+
<module>spring-boot-ctx-fluent</module>
266+
<module>java-ee-8-security-api</module>
267+
<module>spring-webflux-amqp</module>
267268
</modules>
268269

269270
<dependencies>

spring-boot-ctx-fluent/pom.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>com.baeldung</groupId>
6-
<artifactId>ctxexample</artifactId>
6+
<artifactId>spring-boot-ctx-fluent</artifactId>
77
<version>0.0.1-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

10-
<name>ctxexample</name>
11-
<url>http://maven.apache.org</url>
10+
<parent>
11+
<artifactId>parent-boot-2</artifactId>
12+
<groupId>com.baeldung</groupId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<relativePath>../parent-boot-2</relativePath>
15+
</parent>
1216

13-
<properties>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
</properties>
16-
<parent>
17-
<groupId>org.springframework.boot</groupId>
18-
<artifactId>spring-boot-starter-parent</artifactId>
19-
<version>2.0.0.RELEASE</version>
20-
</parent>
2117
<dependencies>
2218
<dependency>
2319
<groupId>org.springframework.boot</groupId>
2420
<artifactId>spring-boot-starter-web</artifactId>
2521
</dependency>
2622
</dependencies>
23+
24+
<properties>
25+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26+
</properties>
27+
2728
</project>

spring-boot-ctx-fluent/src/main/java/com/baeldung/App.java

Lines changed: 0 additions & 22 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
package com.baeldung.web;
1+
package com.baeldung.ctx1;
22

33
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.ComponentScan;
66
import org.springframework.context.annotation.Configuration;
77
import org.springframework.context.annotation.PropertySource;
88

9-
import com.baeldung.services.IHomeService;
9+
import com.baeldung.parent.IHomeService;
1010

1111
@Configuration
12-
@ComponentScan("com.baeldung.web")
12+
@ComponentScan("com.baeldung.ctx1")
13+
@PropertySource("classpath:ctx1.properties")
1314
@EnableAutoConfiguration
14-
@PropertySource("classpath:web-app.properties")
15-
public class WebConfig {
15+
public class Ctx1Config {
1616

1717
@Bean
1818
public IHomeService homeService() {
1919
return new GreetingService();
2020
}
21+
2122
}

spring-boot-ctx-fluent/src/main/java/com/baeldung/web/HomeController.java renamed to spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package com.baeldung.web;
1+
package com.baeldung.ctx1;
22

33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.stereotype.Controller;
55
import org.springframework.web.bind.annotation.GetMapping;
66
import org.springframework.web.bind.annotation.ResponseBody;
77

8-
import com.baeldung.services.IHomeService;
8+
import com.baeldung.parent.IHomeService;
99

1010
@Controller
11-
public class HomeController {
11+
public class Ctx1Controller {
1212

1313
@Autowired
1414
IHomeService homeService;

spring-boot-ctx-fluent/src/main/java/com/baeldung/web/GreetingService.java renamed to spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/GreetingService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.baeldung.web;
1+
package com.baeldung.ctx1;
22

33
import org.springframework.stereotype.Service;
44

5-
import com.baeldung.services.IHomeService;
5+
import com.baeldung.parent.IHomeService;
66

77
@Service
88
public class GreetingService implements IHomeService {
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package com.baeldung.rest;
1+
package com.baeldung.ctx2;
22

33
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
44
import org.springframework.context.annotation.ComponentScan;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.context.annotation.PropertySource;
77

88
@Configuration
9-
@ComponentScan("com.baeldung.rest")
9+
@ComponentScan("com.baeldung.ctx2")
1010
@EnableAutoConfiguration
11-
@PropertySource("classpath:rest-app.properties")
12-
public class RestConfig {
11+
@PropertySource("classpath:ctx2.properties")
12+
public class Ctx2Config {
1313

1414
}

spring-boot-ctx-fluent/src/main/java/com/baeldung/rest/GreetingController.java renamed to spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package com.baeldung.rest;
1+
package com.baeldung.ctx2;
22

33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.web.bind.annotation.GetMapping;
55
import org.springframework.web.bind.annotation.RestController;
66

7-
import com.baeldung.services.IHomeService;
7+
import com.baeldung.parent.IHomeService;
88

99
@RestController
10-
public class GreetingController {
10+
public class Ctx2Controller {
1111

1212
@Autowired
1313
IHomeService homeService;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.parent;
2+
3+
import org.springframework.boot.WebApplicationType;
4+
import org.springframework.boot.builder.SpringApplicationBuilder;
5+
6+
import com.baeldung.ctx1.Ctx1Config;
7+
import com.baeldung.ctx2.Ctx2Config;
8+
9+
public class App {
10+
public static void main(String[] args) {
11+
new SpringApplicationBuilder().parent(ParentConfig.class)
12+
.web(WebApplicationType.NONE)
13+
.child(Ctx1Config.class)
14+
.web(WebApplicationType.SERVLET)
15+
.sibling(Ctx2Config.class)
16+
.web(WebApplicationType.SERVLET)
17+
.run(args);
18+
}
19+
}

spring-boot-ctx-fluent/src/main/java/com/baeldung/services/HomeService.java renamed to spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/HomeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.services;
1+
package com.baeldung.parent;
22

33
import org.springframework.stereotype.Service;
44

0 commit comments

Comments
 (0)