This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9199bbd
commit 10c737d
Showing
4 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ services: | |
image: my-java-app | ||
container_name: my-java-app | ||
ports: | ||
- "4001:8080" # real port:app port | ||
- "4001:8080" |
32 changes: 15 additions & 17 deletions
32
...er/my-java-app/app/src/main/java/es/msanchez/frameworks/java/spring/boot/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
package es.msanchez.frameworks.java.spring.boot; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.AutoConfigurationPackage; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@EnableAutoConfiguration | ||
@SpringBootApplication | ||
public class Application { | ||
|
||
public static void main(final String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
public static void main(final String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
@Bean | ||
public CommandLineRunner commandLineRunner(final ApplicationContext context) { | ||
return args -> { | ||
log.info("Beans provided by Spring Boot:"); | ||
final List<String> beanNames = Arrays.asList(context.getBeanDefinitionNames()); | ||
beanNames.forEach(bean -> log.debug("Bean name '{}'", bean)); | ||
}; | ||
@Bean | ||
public CommandLineRunner commandLineRunner(final ApplicationContext context) { | ||
return args -> { | ||
log.info("Beans provided by Spring Boot:"); | ||
final List<String> beanNames = Arrays.asList(context.getBeanDefinitionNames()); | ||
beanNames.forEach(bean -> log.debug("Bean name '{}'", bean)); | ||
}; | ||
|
||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...va-app/app/src/main/java/es/msanchez/frameworks/java/spring/boot/config/SpringConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package es.msanchez.frameworks.java.spring.boot.config; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ComponentScan(basePackages = { "es.msanchez.frameworks.java.spring.boot.**" }) | ||
public class SpringConfig { | ||
|
||
} |
10 changes: 6 additions & 4 deletions
10
...app/src/main/java/es/msanchez/frameworks/java/spring/boot/controller/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package es.msanchez.frameworks.java.spring.boot.controller; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/my-java-app") | ||
public class HelloController { | ||
|
||
@RequestMapping("/hello-world") | ||
public String index() { | ||
return "Hello world from Docker!"; | ||
} | ||
@GetMapping("hello-world") | ||
public String index() { | ||
return "Hello world from Docker!"; | ||
} | ||
|
||
} |