Spring Boot Deployment Strategy - spring-boot

Am implementing the swagger 2 using Spring Boot. Using Dependencies-
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
It works good. But want to implement swagger in such a way that in production
swagger does not get deployed. Also will it be possible to host the swagger build differently than the application build on different host machines?

There are two approaches to do this.
Maven profile
By intrudue a maven profile like 'swagger' and add the springfox-swagger-ui related depdencenty to this maven profile. As maybe you need to use some swagger annotations in the java code, so it cannot eliminate the springfox-swagger2 dependency.
Spring profile( should be more better than option 1 )
For a standard spring-boot swagger2 config class, for example you can add the #Profile("swagger") annoation to enable the swagger2 integration only when add the spring.profiles.active=swagger in app running.
For the different host machines, I has no idea about that, but as my understanding, swagger will select all the spring boot endpoints so suppose you cannot leave them alone. But there is a library which can provides a way to publish springfox-swagger2 on spring boot actuator. so you can add management.port=8181 property in application.properties to makes spring-boot-actuator run on another TCP port.

Related

What is the web dependency in the Kotlin Spring Boot tutorial?

In the Kotlin Spring Boot tutorial it asks you to include the web dependency, like this:
but in the actual Spring Boot initializr, I don't see that:
What's the web dependency that's required? Is it Spring Web Starter? Is this tutorial out of date and/or obsolete?
spring web starter is the one you need to select it's what they refer to in the tutorial.
its the full name for it.
if you look in the tutorial they later show the pom.xml There you can see that they have declared the:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
and the tuturial still seems okey so go for it.

Spring: spring-data-mongodb or spring-boot-starter-data-mongodb

Which's the difference between
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
and,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
I'm developing an spring boot service.
spring-boot-starter-data-mongodb contains configuration classes for Spring Boot. It also includes the spring-data-mongodb library so you would only need to include the start in your boot app:
https://search.maven.org/artifact/org.springframework.boot/spring-boot-starter-data-mongodb/2.0.5.RELEASE/jar
spring-boot-starter-data-mongodb is a spring boot starter pom. For more information on starters:
spring-boot-starters
Dependency management is a critical aspects of any complex project. And doing this manually is less than ideal; the more time you spent on it the less time you have on the other important aspects of the project.
Spring Boot starters were built to address exactly this problem. Starter POMs are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors.

Spring Boot 1.5.9 - Jaxb2Marshaller

Trying to learn Spring Boot. Taking existing Spring application and rebuilding it in a new boot project. One of my clasess relies upon a dependency org.springframework -> spring-oxm which is for the Jaxb2Marshaller.
In my Spring Boot project when I add this dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
When I add the above to my POM it never pulls the jar in so I cannot import the Jaxb2Marshaller. I believe Spring Boot logic is keeping this from being pulled in because of the version. I tried other versions, but no luck. What is the proper way to pull in this spring dependency with the right version?

Spring Initializer - Zipkin Server missing?

Can't see Zipkin Server when using Spring Initializer . Has it been removed? What is the alternative?
Zipkin Server is not part of Spring initializers. You have to use the official release of the Zipkin server
https://github.com/openzipkin/zipkin#quick-start
And custom servers are not supported anymore meaning you can't use #EnableZipkinServer anymore since 2.7
https://github.com/openzipkin/zipkin#quick-start
Lately I have been trying the same and couldn't find that option in initializer. I am just posting this if anyone encounters the same issues and lands on this page. You can refer below sample GitHub project which is consists of four micro services ( zipkin server, client, rest service, and Eureka ) using Edgware release with latest version of sleuth.
Sample Zipkin Server/Client
Create spring starter project and add the below dependencies manually.
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.12.0</version>
</dependency>

Maven : Spring 4 + Spring Security

Can you explain to me how to properly build a web app with Spring? I know that the latest version of Spring framework is 4.0.0.RELEASE, but the latest version of Spring Security is 3.2.0.RELEASE, and it depends on spring 3.2.6... maybe i'm wrong :)
How can I integrate it with Maven?
Can I use Spring 4 or must I use the previous version?
What is the proper way?
If it`s not hard for you could you show me you pom.xml?
You should be fine using Spring 4. As described in the documentation:
"Spring Security builds against Spring Framework 3.2.6.RELEASE, but is also tested against Spring Framework 4.0.0.RELEASE. This means you can use Spring Security 3.2.0.RELEASE with Spring Framework 4.0.0.RELEASE."
They go on to describe strategies for integrating Spring 4 with Spring Security in your project. Like this one:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Resources