<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dpkupreti on Medium]]></title>
        <description><![CDATA[Stories by Dpkupreti on Medium]]></description>
        <link>https://medium.com/@dpkupreti3?source=rss-24214dcc103b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-pFyM8CkZf8zbkAZ</url>
            <title>Stories by Dpkupreti on Medium</title>
            <link>https://medium.com/@dpkupreti3?source=rss-24214dcc103b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 10:40:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dpkupreti3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SpringBoot — A magic spell!!]]></title>
            <link>https://medium.com/@dpkupreti3/springboot-a-magic-spell-58031661ed31?source=rss-24214dcc103b------2</link>
            <guid isPermaLink="false">https://medium.com/p/58031661ed31</guid>
            <dc:creator><![CDATA[Dpkupreti]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 15:39:59 GMT</pubDate>
            <atom:updated>2020-07-13T16:17:37.359Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding SpringBoot — A magic spell!!</h3><p>Sometimes a developer forages someone who could be his God Mother who could rescue him in dilemma during code adversities. Designing the most complex architecture to meet the needful of applications brings onto the table different challenges like database usages, modularity, MVC compliances and many more.</p><p>Voila!! The code fairy god mother SpringBoot was released in April 2014, as <strong>spring boot</strong> 1.0. 0 .</p><blockquote><strong>Let’s start with the magic.</strong></blockquote><p>The SpringApplication class helps to bootstrap the spring functionality through main() method. Most cases, the delegation goes to SpringApplication.run method.Example-:</p><p><strong>public</strong> <strong>static</strong> <strong>void</strong> <strong>main</strong>(String[] args) { SpringApplication.run({<em>YourSpringConfigurationApplication}</em>.class, args); }</p><p>When you run your main method class vis a vis Spring configuration class the console looks like this-:</p><pre>.   ____          _            __ _ _<br> /\\ / ___&#39;_ __ _ _(_)_ __  __ _ \ \ \ \<br>( ( )\___ | &#39;_ | &#39;_| | &#39;_ \/ _` | \ \ \ \<br> \\/  ___)| |_)| | | | | || (_| |  ) ) ) )<br>  &#39;  |____| .__|_| |_|_| |_\__, | / / / /<br> =========|_|==============|___/=/_/_/_/<br> :: Spring Boot ::   v2.3.1.RELEASE<br><br>2019-04-31 13:09:54.117  <strong>INFO</strong> 56603 --- [           main] o.s.b.s.app.SampleApplication            : Starting SampleApplication v0.1.0 on mycomputer with PID 56603 (/apps/myapp.jar started by pwebb)<br>2019-04-31 13:09:54.166  <strong>INFO</strong> 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<br>2019-04-01 13:09:56.912  <strong>INFO</strong> 41370 --- [           main] .t.TomcatServletWebServerFactory : Server initialized with port: 8080<br>2019-04-01 13:09:57.501  <strong>INFO</strong> 41370 --- [           main] o.s.b.s.app.SampleApplication            : Started SampleApplication in 2.992 seconds (JVM running for 3.658)</pre><p>As you see above, the logging information is INFO which is a default logging level. The application version is determined from the implementation version of spring main application class.</p><p>If you need to turn off your starter logs like above, you can simply go to your properties file and set the property like spring.main.log-startup-info to false .</p><p>Above representation is handled through Banner that can be changed by adding a banner.txt file to your classpath or by setting the spring.banner.location property to the location of such a file. If the file has an encoding other than UTF-8, you can set spring.banner.charset. In addition to a text file, you can also add a banner.gif, banner.jpg, or banner.png image file to your classpath or set the spring.banner.image.location property.</p><p>Table 1. Banner variablesVariableDescription</p><p>${application.version}</p><p>The version number of your application, as declared in MANIFEST.MF. For example, Implementation-Version: 1.0 is printed as 1.0.</p><p>${application.formatted-version}</p><p>The version number of your application, as declared in MANIFEST.MF and formatted for display (surrounded with brackets and prefixed with v). For example (v1.0).</p><p>${spring-boot.version}</p><p>The Spring Boot version that you are using. For example 2.3.1.RELEASE.</p><p>${spring-boot.formatted-version}</p><p>The Spring Boot version that you are using, formatted for display (surrounded with brackets and prefixed with v). For example (v2.3.1.RELEASE).</p><p>${Ansi.NAME} (or ${AnsiColor.NAME}, ${AnsiBackground.NAME}, ${AnsiStyle.NAME})</p><p>Where NAME is the name of an ANSI escape code. See <a href="https://github.com/spring-projects/spring-boot/tree/v2.3.1.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java">AnsiPropertySource</a> for details.</p><p>${application.title}</p><p>The title of your application, as declared in MANIFEST.MF. For example Implementation-Title: MyApp is printed as MyApp.</p><p><strong>Will my startup ever fail?</strong></p><p>If the spring application starts on a server port let say 8080 and during which it detects the port is already used by some application, then the startup fails like below.</p><pre>***************************<br>APPLICATION FAILED TO START<br>***************************<br><br>Description:<br><br>Embedded servlet container failed to start. Port 8080 was already in use.<br><br>Action:<br><br>Identify and stop the process that&#39;s listening on port 8080 or configure this application to listen on another port.</pre><p>How does this work?</p><p>SpringBoot defines various failure analysers to detect faults or issues due to which it could not start the application. These are commonly known as Spring’s FailureAnalyzer. You can create your own failure analyser according to your requirement like <strong><em>org.springframework.boot.diagnostics.FailureAnalyzer</em></strong><em>=\ com.example.ProjectConstraintViolationFailureAnalyzer</em></p><p>If no failure analyzers are able to handle the exception, you can still display the full conditions report to better understand what went wrong. To do so, you need to <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config">enable the </a><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config">debug property</a> or <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-custom-log-levels">enable </a><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-custom-log-levels">DEBUG logging</a> for org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.</p><p><strong>How Beans are initialised here?</strong></p><p>SpringBoot allows you to initialise the bean in a lazy loading manner. When you opt for this option then it doesn’t go on initialising all the beans available. Rather the ones which are needed are only initialised hence the startup time is less. The beans are however initialised during respective Http request call.</p><p><strong>Cons</strong>-:</p><p><em>Scenario 1)</em>- There are 2 beans A and B. We have opted for Lazy initialisation. Bean B has some runtime issue and during startup only Bean A is initialised and everything is fine so far. When a request is received and Spring tries to initialise Bean B, BOOOOOOM!! Application falls apart.</p><p><em>Scenario 2</em>)- Let say there are 100 beans to be initialised. And we register JVM heap size roughly 2GB. During startup, bean occupies the heap. More bean initialising would acquire more java heap. Worst scenario, your estimation of 2GB went wrong. And OutOfMemory error awaits you.</p><p>For these reasons, lazy initialisation is not enabled by default and it is recommended that fine-tuning of the JVM’s heap size is done before enabling lazy initialisation.</p><blockquote><strong>spring.main.lazy-initialization</strong>=true/false</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58031661ed31" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>