Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
docker-compose: fixed spring DI
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCodes committed Jun 7, 2019
1 parent 9199bbd commit 10c737d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ services:
image: my-java-app
container_name: my-java-app
ports:
- "4001:8080" # real port:app port
- "4001:8080"
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));
};

}
}

}
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 {

}
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!";
}

}

0 comments on commit 10c737d

Please sign in to comment.