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>performance-tests</module>
|
||||
<module>twilio</module>
|
||||
<module>spring-boot-ctx-fluent</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -3,25 +3,26 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>ctxexample</artifactId>
|
||||
<artifactId>spring-boot-ctx-fluent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ctxexample</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<parent>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</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.context.annotation.Bean;
|
||||
|
@ -6,16 +6,17 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import com.baeldung.services.IHomeService;
|
||||
import com.baeldung.parent.IHomeService;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("com.baeldung.web")
|
||||
@ComponentScan("com.baeldung.ctx1")
|
||||
@PropertySource("classpath:ctx1.properties")
|
||||
@EnableAutoConfiguration
|
||||
@PropertySource("classpath:web-app.properties")
|
||||
public class WebConfig {
|
||||
public class Ctx1Config {
|
||||
|
||||
@Bean
|
||||
public IHomeService homeService() {
|
||||
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.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.baeldung.services.IHomeService;
|
||||
import com.baeldung.parent.IHomeService;
|
||||
|
||||
@Controller
|
||||
public class HomeController {
|
||||
public class Ctx1Controller {
|
||||
|
||||
@Autowired
|
||||
IHomeService homeService;
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung.web;
|
||||
package com.baeldung.ctx1;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.services.IHomeService;
|
||||
import com.baeldung.parent.IHomeService;
|
||||
|
||||
@Service
|
||||
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.context.annotation.ComponentScan;
|
||||
|
@ -6,9 +6,9 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("com.baeldung.rest")
|
||||
@ComponentScan("com.baeldung.ctx2")
|
||||
@EnableAutoConfiguration
|
||||
@PropertySource("classpath:rest-app.properties")
|
||||
public class RestConfig {
|
||||
@PropertySource("classpath:ctx2.properties")
|
||||
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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baeldung.services.IHomeService;
|
||||
import com.baeldung.parent.IHomeService;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
public class Ctx2Controller {
|
||||
|
||||
@Autowired
|
||||
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;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.services;
|
||||
package com.baeldung.parent;
|
||||
|
||||
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.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("com.baeldung.services")
|
||||
public class ServiceConfig {}
|
||||
@ComponentScan("com.baeldung.parent")
|
||||
public class ParentConfig {}
|
|
@ -1,5 +1,5 @@
|
|||
server.port=8081
|
||||
server.servlet.context-path=/rest
|
||||
server.servlet.context-path=/ctx1
|
||||
#logging.level=debug
|
||||
spring.application.admin.enabled=false
|
||||
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.jmx-name=org.springframework.boot:type=WebAdmin,name=SpringWebApplication
|
Loading…
Reference in New Issue