### Install and Manage init.d Service Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Commands for symlinking, starting, and configuring automatic startup for an init.d service. ```bash $ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp ``` ```bash $ service myapp start ``` ```bash $ update-rc.d myapp defaults ``` -------------------------------- ### Application Properties Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/configuration-metadata.html Example of setting configuration properties within an application.properties file. ```properties server.port=9090 server.servlet.path=/home ``` -------------------------------- ### application.yml Configuration Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-external-config.html Example of a YAML file defining configuration properties for an application. ```yaml acme: remote-address: 192.168.1.1 security: username: admin roles: - USER - ADMIN ``` -------------------------------- ### Spring Boot Application Startup Output Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-first-application.html This is an example of the output you will see when your Spring Boot application starts successfully. It includes version information and startup time. ```bash $ mvn spring-boot:run . ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\[__] | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.6.RELEASE) ....... . . . ....... . . . (log output here) ....... . . . ........ Started Example in 2.222 seconds (JVM running for 6.514) ``` -------------------------------- ### Start Spring Boot Application Service Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/deployment-install.html Start a Spring Boot application installed as an init.d service using the service command. Ensure the application is correctly linked in /etc/init.d. ```bash $ service myapp start ``` -------------------------------- ### Install Spring Boot Application as init.d Service Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/deployment-install.html Create a symbolic link for a fully executable Spring Boot JAR to the init.d directory to manage it as a system service. This allows standard start, stop, and restart commands. ```bash $ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp ``` -------------------------------- ### Boxfuse Deployment Output Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cloud-deployment.html Example output demonstrating the Boxfuse deployment process on AWS, including image fusing, resource provisioning, and deployment completion. ```text Fusing Image for myapp-1.0.jar ... Image fused in 00:06.838s (53937 K) -> axelfontaine/myapp:1.0 Creating axelfontaine/myapp ... Pushing axelfontaine/myapp:1.0 ... Verifying axelfontaine/myapp:1.0 ... Creating Elastic IP ... Mapping myapp-axelfontaine.boxfuse.io to 52.28.233.167 ... Waiting for AWS to create an AMI for axelfontaine/myapp:1.0 in eu-central-1 (this may take up to 50 seconds) ... AMI created in 00:23.557s -> ami-d23f38cf Creating security group boxfuse-sg_axelfontaine/myapp:1.0 ... Launching t2.micro instance of axelfontaine/myapp:1.0 (ami-d23f38cf) in eu-central-1 ... Instance launched in 00:30.306s -> i-92ef9f53 Waiting for AWS to boot Instance i-92ef9f53 and Payload to start at http://52.28.235.61/ ... Payload started in 00:29.266s -> http://52.28.235.61/ Remapping Elastic IP 52.28.233.167 to i-92ef9f53 ... Waiting 15s for AWS to complete Elastic IP Zero Downtime transition ... Deployment completed successfully. axelfontaine/myapp:1.0 is up and running at http://myapp-axelfontaine.boxfuse.io/ ``` -------------------------------- ### Install Spring Boot CLI with SDKMAN! Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Installs the Spring Boot CLI using the SDKMAN! package manager. Use this to manage multiple versions of the CLI. ```bash $ sdk install springboot $ spring --version ``` -------------------------------- ### Install Spring Boot CLI with Scoop Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Installs the Spring Boot CLI on Windows using the Scoop package manager. Scoop installs `spring` to `~/scoop/apps/springboot/current/bin`. ```bash > scoop bucket add extras > scoop install springboot ``` -------------------------------- ### Spring Boot Startup Log Output Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Example of the console output generated during a successful application startup. ```text . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: v2.0.6.RELEASE 2013-07-31 00:08:16.117 INFO 56603 --- [ main] o.s.b.s.app.SampleApplication : Starting SampleApplication v0.1.0 on mycomputer with PID 56603 (/apps/myapp.jar started by pwebb) 2013-07-31 00:08:16.166 INFO 56603 --- [ main] ationConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6e5a8246: startup date [Wed Jul 31 00:08:16 PDT 2013]; root of context hierarchy 2014-03-04 13:09:54.912 INFO 41370 --- [ main] .t.TomcatServletWebServerFactory : Server initialized with port: 8080 2014-03-04 13:09:56.501 INFO 41370 --- [ main] o.s.b.s.app.SampleApplication : Started SampleApplication in 2.992 seconds (JVM running for 3.658) ``` -------------------------------- ### Remote Client Application Output Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/using-boot-devtools.html Example log output showing a successful startup of the RemoteSpringApplication. ```text . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | | _ \___ _ __ ___| |_ ___ \ \ \ \ \\/ ___)| |_)| | | | | || (_| []::::::[] / -_) ' \/ _ \ _/ -_) ) ) ) ) ' |____| .__|_| |_|_| |_| |_\__, | |_|_\___|_|_|_\___/\__\___|/ / / / =========|_|==============|___/===================================/_/_/_/ :: Spring Boot Remote :: 2.0.6.RELEASE 2015-06-10 18:25:06.632 INFO 14938 --- [ main] o.s.b.devtools.RemoteSpringApplication : Starting RemoteSpringApplication on pwmbp with PID 14938 (/Users/pwebb/projects/spring-boot/code/spring-boot-devtools/target/classes started by pwebb in /Users/pwebb/projects/spring-boot/code/spring-boot-samples/spring-boot-sample-devtools) 2015-06-10 18:25:06.671 INFO 14938 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2a17b7b6: startup date [Wed Jun 10 18:25:06 PDT 2015]; root of context hierarchy 2015-06-10 18:25:07.043 WARN 14938 --- [ main] o.s.b.d.r.c.RemoteClientConfiguration : The connection to http://localhost:8080 is insecure. You should use a URL starting with 'https://'. 2015-06-10 18:25:07.074 INFO 14938 --- [ main] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2015-06-10 18:25:07.130 INFO 14938 --- [ main] o.s.b.devtools.RemoteSpringApplication : Started RemoteSpringApplication in 0.74 seconds (JVM running for 1.105) ``` -------------------------------- ### Startup Failure Error Message Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Example of the error message displayed when a port conflict prevents the embedded servlet container from starting. ```text *************************** APPLICATION FAILED TO START *************************** Description: Embedded servlet container failed to start. Port 8080 was already in use. Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. ``` -------------------------------- ### Manual Hint Example for Map Keys Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Example of providing manual hints for the keys of a map property. ```APIDOC ## Manual Hint Example for Map Keys Assume a `sample.contexts` maps magic `String` values to an integer, as shown in the following example: ```java _@ConfigurationProperties("sample")_ public class SampleProperties { private Map contexts; // getters and setters } ``` The magic values are (in this example) are`sample1` and `sample2`. In order to offer additional content assistance for the keys, you could add the following JSON to the manual metadata of the module: ```json { "hints": [ { "name": "sample.contexts.keys", "values": [ { "value": "sample1" }, { "value": "sample2" } ] } ] } ``` | Tip | |---| | We recommend that you use an `Enum` for those two values instead. If your IDE supports it, this is by far the most effective approach to auto-completion. | ``` -------------------------------- ### Start Ant with Library Path Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/build-tool-plugins-antlib.html Use the -lib option to include the spring-boot-antlib jar when executing Ant. ```bash $ ant -lib ``` -------------------------------- ### Install Development Version of Spring Boot CLI with SDKMAN! Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Installs a development version of the Spring Boot CLI using SDKMAN!, pointing to a local build. This is useful when developing features for the CLI itself. ```bash $ sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-boot-cli-2.0.6.RELEASE-bin/spring-2.0.6.RELEASE/ $ sdk default springboot dev $ spring --version ``` ```text Spring CLI v2.0.6.RELEASE ``` -------------------------------- ### Install Spring Boot CLI with Homebrew Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Installs the Spring Boot CLI on macOS using the Homebrew package manager. Homebrew installs `spring` to `/usr/local/bin`. ```bash $ brew tap pivotal/tap $ brew install springboot ``` -------------------------------- ### List Available Spring Boot Versions with SDKMAN! Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Lists all installed and available versions of the Spring Boot CLI managed by SDKMAN!. ```bash $ sdk ls springboot ``` ```text ================================================================================ Available Springboot Versions ================================================================================ > + dev * 2.0.6.RELEASE ================================================================================ + - local version * - installed > - currently in use ================================================================================ ``` -------------------------------- ### Example Configuration Properties Class Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Demonstrates a Java class annotated with `@ConfigurationProperties` that the annotation processor will inspect. ```java _@ConfigurationProperties(prefix="server")_ public class ServerProperties { private String name; private Host host; // ... getter and setters public static class Host { private String ip; private int port; // ... getter and setters } } ``` -------------------------------- ### Example Info Endpoint Response Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/production-ready-endpoints.html This JSON snippet shows an example of the additional entry that appears in the info endpoint response when a custom `ExampleInfoContributor` is registered. ```json { "example": { "key" : "value" } } ``` -------------------------------- ### Define Application Configuration Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Example of a main application class using Spring Boot annotations. ```java _@SpringBootApplication_ _@EnableBatchProcessing_ public class SampleApplication { ... } ``` -------------------------------- ### Install Local Spring Boot CLI Development Version with SDKMAN! Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Installs a local development version of the Spring Boot CLI using SDKMAN!. This is useful for testing features you are developing for the CLI. It points to your build location, ensuring `spring` is always up-to-date with your rebuilds. ```bash $ sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-boot-cli-2.0.6.RELEASE-bin/spring-2.0.6.RELEASE/ $ sdk default springboot dev $ spring --version ``` -------------------------------- ### Equivalent Properties File for YAML Configuration Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-properties-and-configuration.html This `application.properties` file represents the same configuration as the provided YAML example, demonstrating the flattened structure of properties. ```properties spring.application.name=cruncher spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost/test server.port=9000 ``` -------------------------------- ### Install CLI extensions Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cli-using-the-cli.html Adds extensions to the CLI using artifact coordinates. ```bash $ spring install com.example:spring-boot-cli-extension:1.0.0.RELEASE ``` -------------------------------- ### List Available Springboot Versions with SDKMAN! Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Lists all available Springboot versions managed by SDKMAN!, indicating local, installed, and currently in-use versions. ```bash $ sdk ls springboot ``` -------------------------------- ### Run Spring Boot Application with Maven Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Use the `spring-boot:run` Maven goal to start the application. Ensure you are in the root project directory. ```bash $ mvn spring-boot:run . ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\[__] | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.6.RELEASE) ....... ....... ....... ........ Started Example in 2.222 seconds (JVM running for 6.514) ``` -------------------------------- ### Define DataSource Properties in application.properties Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-data-access.html Example configuration properties for two separate data sources using custom namespaces. ```properties app.datasource.first.url=jdbc:mysql://localhost/first app.datasource.first.username=dbuser app.datasource.first.password=dbpass app.datasource.first.configuration.maximum-pool-size=30 app.datasource.second.url=jdbc:mysql://localhost/second app.datasource.second.username=dbuser app.datasource.second.password=dbpass app.datasource.second.max-total=30 ``` -------------------------------- ### Quick-start Spring CLI Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Creates and runs a simple Groovy web application using the Spring Boot CLI. The first run may be slow due to dependency downloads. ```groovy _@RestController_ class ThisWillActuallyRun { _@RequestMapping("/")_ String home() { "Hello World!" } } ``` ```bash $ spring run app.groovy ``` ```text Hello World! ``` -------------------------------- ### Initialize a new project with Spring CLI Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cli-using-the-cli.html Creates a new project using start.spring.io with specified dependencies. ```bash $ spring init --dependencies=web,data-jpa my-project Using service at https://start.spring.io Project extracted to '/Users/developer/example/my-project' ``` -------------------------------- ### Access Quick-start Application Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html The expected output when accessing the running quick-start application at `localhost:8080` in a web browser. ```text Hello World! ``` -------------------------------- ### REST Controller Example in Spring MVC Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-developing-web-applications.html A typical @RestController that handles HTTP requests for user data. It demonstrates mapping GET, DELETE requests to specific user paths and retrieving user customers. ```java @RestController @RequestMapping(value="/users") public class MyRestController { @RequestMapping(value="/{user}", method=RequestMethod.GET) public User getUser(@PathVariable Long user) { // ... } @RequestMapping(value="/{user}/customers", method=RequestMethod.GET) List getUserCustomers(@PathVariable Long user) { // ... } @RequestMapping(value="/{user}", method=RequestMethod.DELETE) public User deleteUser(@PathVariable Long user) { // ... } } ``` -------------------------------- ### Any Value Provider Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/configuration-metadata.html Demonstrates the 'any' provider for the 'system.state' property, allowing 'on' and 'off' as specific values while also permitting any additional values. ```json { "hints": [ { "name": "system.state", "values": [ { "value": "on" }, { "value": "off" } ], "providers": [ { "name": "any" } ] } ] } ``` -------------------------------- ### Initialize a custom Gradle project Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cli-using-the-cli.html Creates a project with specific build, Java version, dependency, and packaging configurations. ```bash $ spring init --build=gradle --java-version=1.8 --dependencies=websocket --packaging=war sample-app.zip Using service at https://start.spring.io Content saved to 'sample-app.zip' ``` -------------------------------- ### Install Spring Boot CLI with MacPorts Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Installs the Spring Boot CLI on macOS using the MacPorts package manager. ```bash $ sudo port install spring-boot-cli ``` -------------------------------- ### Example Repackage Implementation Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Demonstrates how to use the `Repackager` class from `spring-boot-loader-tools` to repackage an existing JAR file into a self-contained executable archive. It shows how to set backup options and handle nested libraries. ```java Repackager repackager = new Repackager(sourceJarFile); repackager.setBackupSource(false); repackager.repackage(new Libraries() { _@Override_ public void doWithLibraries(LibraryCallback callback) throws IOException { // Build system specific implementation, callback for each dependency // callback.library(new Library(nestedFile, LibraryScope.COMPILE)); } }); ``` -------------------------------- ### Get Help for a Specific Spring CLI Command Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cli-using-the-cli.html Use 'spring help ' to get detailed usage information for a specific command, such as 'run'. ```bash $ spring help run spring run - Run a spring groovy script usage: spring run [options] [--] [args] Option Description ------ ----------- --autoconfigure [Boolean] Add autoconfigure compiler transformations (default: true) --classpath, -cp Additional classpath entries -e, --edit Open the file with the default system editor --no-guess-dependencies Do not attempt to guess dependencies --no-guess-imports Do not attempt to guess imports -q, --quiet Quiet logging -v, --verbose Verbose logging of dependency resolution --watch Watch the specified file for changes ``` -------------------------------- ### Package the application Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-first-application.html Run the Maven package command to build the project and generate the executable jar. ```bash $ mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building myproject 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] .... [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myproject --- [INFO] Building jar: /Users/developer/example/spring-boot-example/target/myproject-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.0.6.RELEASE:repackage (default) @ myproject --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### Uninstall CLI extensions Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/cli-using-the-cli.html Removes installed extensions or all additional dependencies. ```bash $ spring uninstall com.example:spring-boot-cli-extension:1.0.0.RELEASE ``` ```bash $ spring uninstall --all ``` -------------------------------- ### Configure Prometheus Scrape Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/production-ready-metrics.html Example configuration for the Prometheus scrape_config in prometheus.yml. ```yaml scrape_configs: - job_name: 'spring' metrics_path: '/actuator/prometheus' static_configs: - targets: ['HOST:PORT'] ``` -------------------------------- ### Configure properties with DataSourceProperties Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Configuration properties for the custom DataSourceProperties setup. ```properties app.datasource.url=jdbc:mysql://localhost/test app.datasource.username=dbuser app.datasource.password=dbpass app.datasource.configuration.maximum-pool-size=30 ``` -------------------------------- ### Quick-start Spring CLI Groovy Application Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Creates a simple Groovy web application file named `app.groovy` and demonstrates how to run it using the `spring run` command. The first run may be slow due to dependency downloads. ```groovy _@RestController_ class ThisWillActuallyRun { _@RequestMapping("/")_ String home() { "Hello World!" } } ``` ```bash $ spring run app.groovy ``` -------------------------------- ### YAML Configuration Example Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-external-config.html Shows a sample YAML structure for defining environment-specific configurations. This structure is automatically supported by Spring Boot when SnakeYAML is on the classpath. ```yaml environments: dev: url: http://dev.example.com name: Developer Setup prod: url: http://another.example.com name: My Cool App ``` -------------------------------- ### Typical Project Layout Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/using-boot-structuring-your-code.html Illustrates a recommended directory structure for a Spring Boot application, organizing classes by feature or domain. ```text com +- example +- myapplication +- Application.java | +- customer | +- Customer.java | +- CustomerController.java | +- CustomerService.java | +- CustomerRepository.java | +- order +- Order.java +- OrderController.java +- OrderService.java +- OrderRepository.java ``` -------------------------------- ### Inject CassandraTemplate Bean Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-nosql.html Example of injecting a CassandraTemplate bean into a Spring component. ```java _@Component_ public class MyBean { private CassandraTemplate template; _@Autowired_ public MyBean(CassandraTemplate template) { this.template = template; } // ... } ``` -------------------------------- ### Display CLI help and version Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Use the spring command without arguments to see usage, or use the version command to check the current CLI version. ```bash $ spring usage: spring [--help] [--version] [] Available commands are: run [options] [--] [args] Run a spring groovy script _... more command help is shown here_ ``` ```bash $ spring version Spring CLI v2.0.6.RELEASE ``` -------------------------------- ### Inject ElasticsearchTemplate Bean Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-nosql.html Example of injecting an ElasticsearchTemplate bean into a Spring component. ```java _@Component_ public class MyBean { private final ElasticsearchTemplate template; public MyBean(ElasticsearchTemplate template) { this.template = template; } // ... } ``` -------------------------------- ### Define Component Scan Configuration Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Example of overriding default component scanning behavior. ```java _@SpringBootApplication_ _@ComponentScan({ "com.example.app", "org.acme.another" })_ public class SampleApplication { ... } ``` -------------------------------- ### Transformed YAML to Properties Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle The resulting property keys after parsing the hierarchical YAML example. ```properties environments.dev.url=http://dev.example.com environments.dev.name=Developer Setup environments.prod.url=http://another.example.com environments.prod.name=My Cool App ``` -------------------------------- ### Java ConfigurationProperties for Map with Key Hints Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/configuration-metadata.html Defines a ConfigurationProperties class with a Map. This example demonstrates how to provide hints for the keys of a map property using JSON. ```java @ConfigurationProperties("sample") public class SampleProperties { private Map contexts; // getters and setters } ``` -------------------------------- ### Injecting a Neo4j Session Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/boot-features-nosql.html Example of injecting an auto-configured Neo4j Session bean into a component. ```java _@Component_ public class MyBean { private final Session session; _@Autowired_ public MyBean(Session session) { this.session = session; } // ... } ``` -------------------------------- ### Use Short Command Line Arguments with Placeholders Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-properties-and-configuration.html Configure `application.properties` to allow short command-line arguments by using placeholders. This example sets the server port, defaulting to 8080 if the 'port' property is not provided. ```properties server.port=${port:8080} ``` -------------------------------- ### Configure 'any' value provider for property hints Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Allows any value to be provided while offering specific suggestions for auto-completion. ```json {"hints": [ { "name": "system.state", "values": [ { "value": "on" }, { "value": "off" } ], "providers": [ { "name": "any" } ] } ]} ``` -------------------------------- ### Build and run an executable JAR Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/build-tool-plugins-maven-plugin.html These commands first build your project artifact using Maven and then execute the generated JAR file using the Java runtime. ```bash $ mvn package $ java -jar target/mymodule-0.0.1-SNAPSHOT.jar ``` -------------------------------- ### SpringApplication Builder with Banner Mode OFF Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-properties-and-configuration.html Example of creating a `SpringApplicationBuilder` and setting the banner mode to OFF programmatically. ```java new SpringApplicationBuilder() .bannerMode(Banner.Mode.OFF) .sources(demo.MyApp.class) .run(args); ``` -------------------------------- ### Testing with MockMvc Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle Configure MockMvc to test web endpoints without starting a full server. ```java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; _@RunWith(SpringRunner.class)_ _@SpringBootTest_ _@AutoConfigureMockMvc_ public class MockMvcExampleTests { _@Autowired_ private MockMvc mvc; _@Test_ public void exampleTest() throws Exception { this.mvc.perform(get("/")).andExpect(status().isOk()) .andExpect(content().string("Hello World")); } } ``` -------------------------------- ### Check Java Version Source: https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/getting-started-installing-spring-boot.html Verify your current Java SDK installation. Ensure you have version 1.8 or higher. ```bash java -version ```