Spring Boot - singhmahabir/allinone-rest-services GitHub Wiki

How to use XML configuration in Spring Boot? Ans: To load XML configuration, we use @ImportResource with @SpringBootApplication annotation.  MyApplication.java @SpringBootApplication @ImportResource("classpath:app-config.xml") public class MyApplication {
public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); }
}

How to use custom banner in Spring Boot application? Ans: We use custom banner as following.  Text Banner: For text banner just create a file named as banner.txt with desired text and keep it at the location src\main\resources.  Image Banner: For image banner just create a file named as banner.gif and keep it at the location src\main\resources. Other file extensions such as jpg, png can also be used. Console should support to display image. 

In the application.properties we can configure following banner properties.  banner.charset: It configures banner encoding. Default is UTF-8  banner.location: It is banner file location. Default is classpath:banner.txt  banner.image.location: It configures banner image file location. Default is classpath:banner.gif. File can also be jpg, png.  banner.image.width: It configures width of the banner image in char. Default is 76.  banner.image.height: It configures height of the banner image in char. Default is based on image height.  banner.image.margin: It is left hand image margin in char. Default is 2.  banner.image.invert: It configures if images should be inverted for dark terminal themes. Default is false.

How to change default server port? Using Java command with --server.port java -jar my-app.jar --server.port=8585 3. Programmatically with SERVER.PORT key.  MyApplication.java @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication application = new SpringApplication(MyApplication.class); Map<String, Object> map = new HashMap<>(); map.put("SERVER.PORT", "8585"); application.setDefaultProperties(map); application.run(args); }
}

How to change context path in Spring Boot application? Ans: We can change context path by configuring property server.servlet.context-path for Spring Boot 2.x and server.contextPath for Spring 1.x in property file as well as in command line as arguments with java command. Find the configuration for Spring Boot 2.x.  Using property file. server.servlet.context-path = /spring-boot-app server.port = 8585 Using java command. java -jar my-app.jar --server.servlet.context-path=/spring-boot-app --server.port=8585 Change context path programmatically.  MyApplication.java import java.util.HashMap; import java.util.Map; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication application = new SpringApplication(MyApplication.class); Map<String, Object> map = new HashMap<>(); map.put("server.servlet.context-path", "/spring-boot-app"); map.put("server.port", "8585"); application.setDefaultProperties(map); application.run(args); }
}

From https://www.concretepage.com/interview/spring-interview/spring-boot-interview-questions

Spring Boot 2.x Minimum Requirement Java 8, JEE7, Servlet 3.1, JMS 2.0, JPA 2.1, JAX-RS 2.0, Bean Validation 1.1, Hibernate 5, Jackson 2.6, EhCache 2.10, JUnit 5 and Tiles 3, Spring-framwork-5.x Tomcat 8.5, Jetty 9.4, WildFly 10 Reactive programming support – Spring Framework 5 embraces Reactive Streams

From https://howtodoinjava.com/spring-5-tutorial/