update spring boot ctx app, rename classes
This commit is contained in:
parent
087f0c24fe
commit
750674b2cd
1
pom.xml
1
pom.xml
@ -259,6 +259,7 @@
|
|||||||
<module>java-spi</module>
|
<module>java-spi</module>
|
||||||
<module>performance-tests</module>
|
<module>performance-tests</module>
|
||||||
<module>twilio</module>
|
<module>twilio</module>
|
||||||
|
<module>spring-boot-ctx-fluent</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,25 +3,26 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>ctxexample</artifactId>
|
<artifactId>spring-boot-ctx-fluent</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ctxexample</name>
|
<parent>
|
||||||
<url>http://maven.apache.org</url>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>2.0.0.RELEASE</version>
|
|
||||||
</parent>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package com.baeldung;
|
|
||||||
|
|
||||||
import org.springframework.boot.WebApplicationType;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
|
|
||||||
import com.baeldung.rest.RestConfig;
|
|
||||||
import com.baeldung.services.ServiceConfig;
|
|
||||||
import com.baeldung.web.WebConfig;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class App {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder().parent(ServiceConfig.class)
|
|
||||||
.web(WebApplicationType.NONE)
|
|
||||||
.child(WebConfig.class)
|
|
||||||
.web(WebApplicationType.SERVLET)
|
|
||||||
.sibling(RestConfig.class)
|
|
||||||
.web(WebApplicationType.SERVLET)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.web;
|
package com.baeldung.ctx1;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -6,16 +6,17 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
import com.baeldung.services.IHomeService;
|
import com.baeldung.parent.IHomeService;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("com.baeldung.web")
|
@ComponentScan("com.baeldung.ctx1")
|
||||||
|
@PropertySource("classpath:ctx1.properties")
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@PropertySource("classpath:web-app.properties")
|
public class Ctx1Config {
|
||||||
public class WebConfig {
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public IHomeService homeService() {
|
public IHomeService homeService() {
|
||||||
return new GreetingService();
|
return new GreetingService();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package com.baeldung.web;
|
package com.baeldung.ctx1;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.baeldung.services.IHomeService;
|
import com.baeldung.parent.IHomeService;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class HomeController {
|
public class Ctx1Controller {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IHomeService homeService;
|
IHomeService homeService;
|
@ -1,8 +1,8 @@
|
|||||||
package com.baeldung.web;
|
package com.baeldung.ctx1;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baeldung.services.IHomeService;
|
import com.baeldung.parent.IHomeService;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GreetingService implements IHomeService {
|
public class GreetingService implements IHomeService {
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.rest;
|
package com.baeldung.ctx2;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
@ -6,9 +6,9 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("com.baeldung.rest")
|
@ComponentScan("com.baeldung.ctx2")
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@PropertySource("classpath:rest-app.properties")
|
@PropertySource("classpath:ctx2.properties")
|
||||||
public class RestConfig {
|
public class Ctx2Config {
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package com.baeldung.rest;
|
package com.baeldung.ctx2;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.baeldung.services.IHomeService;
|
import com.baeldung.parent.IHomeService;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class GreetingController {
|
public class Ctx2Controller {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IHomeService homeService;
|
IHomeService homeService;
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.baeldung.parent;
|
||||||
|
|
||||||
|
import org.springframework.boot.WebApplicationType;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
|
||||||
|
import com.baeldung.ctx1.Ctx1Config;
|
||||||
|
import com.baeldung.ctx2.Ctx2Config;
|
||||||
|
|
||||||
|
public class App {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new SpringApplicationBuilder().parent(ParentConfig.class)
|
||||||
|
.web(WebApplicationType.NONE)
|
||||||
|
.child(Ctx1Config.class)
|
||||||
|
.web(WebApplicationType.SERVLET)
|
||||||
|
.sibling(Ctx2Config.class)
|
||||||
|
.web(WebApplicationType.SERVLET)
|
||||||
|
.run(args);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.services;
|
package com.baeldung.parent;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.services;
|
package com.baeldung.parent;
|
||||||
|
|
||||||
public interface IHomeService {
|
public interface IHomeService {
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.baeldung.services;
|
package com.baeldung.parent;
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("com.baeldung.services")
|
@ComponentScan("com.baeldung.parent")
|
||||||
public class ServiceConfig {}
|
public class ParentConfig {}
|
@ -1,5 +1,5 @@
|
|||||||
server.port=8081
|
server.port=8081
|
||||||
server.servlet.context-path=/rest
|
server.servlet.context-path=/ctx1
|
||||||
#logging.level=debug
|
#logging.level=debug
|
||||||
spring.application.admin.enabled=false
|
spring.application.admin.enabled=false
|
||||||
spring.application.admin.jmx-name=org.springframework.boot:type=AdminRest,name=SpringRestApplication
|
spring.application.admin.jmx-name=org.springframework.boot:type=AdminRest,name=SpringRestApplication
|
@ -1,3 +1,5 @@
|
|||||||
server.port=8080
|
server.port=8082
|
||||||
|
server.servlet.context-path=/ctx2
|
||||||
|
|
||||||
spring.application.admin.enabled=false
|
spring.application.admin.enabled=false
|
||||||
spring.application.admin.jmx-name=org.springframework.boot:type=WebAdmin,name=SpringWebApplication
|
spring.application.admin.jmx-name=org.springframework.boot:type=WebAdmin,name=SpringWebApplication
|
Loading…
x
Reference in New Issue
Block a user