[BAEL-17473] - Initial commit

This commit is contained in:
amit2103
2019-09-27 01:07:06 +05:30
parent 9ad7ed0e2f
commit ed92f5579d
97 changed files with 710 additions and 170 deletions

View File

@@ -0,0 +1,13 @@
package com.baeldung.springbootconfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootConfigurationApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootConfigurationApplication.class, args);
}
}

View File

@@ -0,0 +1,14 @@
package com.baeldung.springbootconfiguration.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingsController {
@GetMapping("/greetings/{username}")
public String getGreetings(@PathVariable("username") String userName) {
return "Hello " + userName + ", Good day...!!!";
}
}

View File

@@ -0,0 +1,38 @@
package com.baeldung.springbootnonwebapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 1. Act as main class for spring boot application
* 2. Also implements CommandLineRunner, so that code within run method
* is executed before application startup but after all beans are effectively created
* @author hemant
*
*/
@SpringBootApplication
public class SpringBootConsoleApplication implements CommandLineRunner {
private static Logger LOG = LoggerFactory.getLogger(SpringBootConsoleApplication.class);
public static void main(String[] args) {
LOG.info("STARTING THE APPLICATION");
SpringApplication.run(SpringBootConsoleApplication.class, args);
LOG.info("APPLICATION FINISHED");
}
/**
* This method will be executed after the application context is loaded and
* right before the Spring Application main method is completed.
*/
@Override
public void run(String... args) throws Exception {
LOG.info("EXECUTING : command line runner");
for (int i = 0; i < args.length; ++i) {
LOG.info("args[{}]: {}", i, args[i]);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.baeldung.springbootsimple;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.boot.web.servlet.support.*;
@SpringBootApplication
public class SpringBootTomcatApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpringBootTomcatApplication.class, args);
}
}

View File

@@ -0,0 +1,18 @@
package com.baeldung.springbootsimple;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.*;
@RestController
public class TomcatController {
@GetMapping(value = "/hello")
public Collection<String> sayHello() {
return IntStream.range(0, 10)
.mapToObj(i -> "Hello number " + i)
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,29 @@
# server configuration
server.port=4010
server.address=127.0.0.1
## Error handling configuration
server.error.whitelabel.enabled=true
server.error.path=/user-error
server.error.include-exception=true
server.error.include-stacktrace=always
## Server connections configuration
server.tomcat.max-threads=200
server.connection-timeout=5s
server.max-http-header-size=8KB
server.tomcat.max-swallow-size=2MB
server.tomcat.max-http-post-size=2MB
## Access logs configuration
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.directory=logs
server.tomcat.accesslog.file-date-format=yyyy-MM-dd
server.tomcat.accesslog.prefix=access_log
server.tomcat.accesslog.suffix=.log
server.tomcat.accesslog.pattern=common
server.tomcat.basedir=tomcat
## Tomcat internal server logs
logging.level.org.apache.tomcat=DEBUG
logging.level.org.apache.catalina=DEBUG

View File

@@ -0,0 +1 @@
spring.main.allow-bean-definition-overriding=true

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@@ -0,0 +1,15 @@
package com.baeldung.springbootconfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringContextIntegrationTest {
@Test
public void contextLoads() {
}
}

View File

@@ -0,0 +1,15 @@
package com.baeldung.springbootconfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringContextTest {
@Test
public void contextLoads() {
}
}

View File

@@ -0,0 +1,16 @@
package com.baeldung.springbootsimple;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringBootTomcatApplicationIntegrationTest {
@Test
public void contextLoads() {
}
}