click below
click below
Normal Size Small Size show me how
Spring Boot
| Question | Answer |
|---|---|
| What are some different ways you can implement exception handling in a Spring application using annotations? 1 of 2 | 1. On a custom exception use the @ResponseStatus annotation to define an HTTP Status value and a reason (message) to handle a custom exception when thrown. |
| What are some different ways you can implement exception handling in a Spring application using annotations? 2 of 2 | 2. Use @ExceptionHandler methods to any controller to specifically handle exceptions thrown by @RequestMapping methods in the same controller. 3. Use @ControllerAdvice to use uniform exception handling techniques accross a whole application. |
| What is the purpose of the Spring Boot Maven Plugin? 1 of 2 | It collects all the jars on the classpath and builds a single, runnable jar, which makes it more convenient to execute and transport your service. |
| What is the purpose of the Spring Boot Maven Plugin? 2 of 2 | It searches for the main method to flag as a runnable class. Provides a built-in dependency resolver that sets the version number to match Spring Boot dependencies. |
| How would you run a Spring Boot application via the command line if you are using Maven? | mvn package && java -jar target/<name-of-jar>.jar |
| What is JNDI? | The Java Naming and Directory Interface (JNDI) is an API that provides naming and directory functionality to applications written in java. |
| What is bean validation? | We use bean validation when we use annotations placed on a fields, methods, or classes to constrain input. Using annotations like: @NotNull, @Null, @Max(int num), @Min(int num) |
| What is JSR 303? | It is the specification for bean validation in JEE. |
| What type of information do we commonly add to the application.properties file? | What type of information do we commonly add to the application.properties file? |
| Is it possible to add any configuration to Spring Boot? | Yes. We can use a file called "application.properties" to add configurations to Spring Boot if we need. This file is location in our resources folder (or Web-INF, depending) |
| What is the @SpringBootApplication annotation? 1 of 3 | The @SpringBootApplication annotation is a convenience annotation that is a combination of the following annotations: @Configuration - Tags the class as the source of bean definitions for the application context |
| What is the @SpringBootApplication annotation? 2 of 3 | @EnableAutoConfiguration - Tells Spring Boot to start adding beans based on classpath setting, other beans, and various property settings |
| What is the @SpringBootApplication annotation? 3 of 3 | @ComponentScan - Tells Spring to look for other components, configurations, and services in the package, allowing it to find the controllers. |
| What are some of the advantages of using Spring Boot over the basic Spring core? | Directly embed a Tomcat server (no need to deploy WAR files) Simplifies your Maven configuration by providing an opinionated starter POM No code generation and no requirement for XML configuration |
| What does adding the 'spring-boot-starter-parent' to you POM do for you? | It allows you to inherit a starter project that has already made decisions about things like what ORM, Object Mapper, and logging to use. |
| What is Spring Boot? | An opinionated view of the Spring platforms and third-party libraries that allows you to start programming with minimal setup. In short, Spring Boot is an opininated approach to configuring Spring MVC. |