This reference guide covers how to use Spring Cloud Kubernetes.
1. Why do you need Spring Cloud Kubernetes?
Spring Cloud Kubernetes provides implementations of well known Spring Cloud interfaces allowing developers to build and run Spring Cloud applications on Kubernetes. While this project may be useful to you when building a cloud native application, it is also not a requirement in order to deploy a Spring Boot app on Kubernetes. If you are just getting started in your journey to running your Spring Boot app on Kubernetes you can accomplish a lot with nothing more than a basic Spring Boot app and Kubernetes itself. To learn more, you can get started by reading the Spring Boot reference documentation for deploying to Kubernetes and also working through the workshop material Spring and Kubernetes.
2. Starters
Starters are convenient dependency descriptors you can include in your
application. Include a starter to get the dependencies and Spring Boot
auto-configuration for a feature set. Starters that begin with spring-cloud-starter-kubernetes-fabric8
provide implementations using the Fabric8 Kubernetes Java Client.
Starters that begin with
spring-cloud-starter-kubernetes-client
provide implementations using the Kubernetes Java Client.
Starter | Features | ||
---|---|---|---|
|
Discovery Client implementation that resolves service names to Kubernetes Services. |
||
|
Load application properties from Kubernetes ConfigMaps and Secrets. Reload application properties when a ConfigMap or Secret changes. |
||
1. DiscoveryClient for KubernetesThis project provides an implementation of Discovery Client
for Kubernetes.
This client lets you query Kubernetes endpoints (see services) by name.
A service is typically exposed by the Kubernetes API server as a collection of endpoints that represent This is something that you get for free by adding the following dependency inside your project: Fabric8 Kubernetes Client
Kubernetes Java Client
To enable loading of the
Then you can inject the client in your code simply by autowiring it, as the following example shows:
You can choose to enable
If, for any reason, you need to disable the
Some Spring Cloud components use the
Spring Cloud Kubernetes can also watch the Kubernetes service catalog for changes and update the
2. Kubernetes native service discoveryKubernetes itself is capable of (server side) service discovery (see: kubernetes.io/docs/concepts/services-networking/service/#discovering-services). Using native kubernetes service discovery ensures compatibility with additional tooling, such as Istio (istio.io), a service mesh that is capable of load balancing, circuit breaker, failover, and much more. The caller service then need only refer to names resolvable in a particular Kubernetes cluster. A simple implementation might use a spring Additionally, you can use Hystrix for:
3. Kubernetes PropertySource implementationsThe most common approach to configuring your Spring Boot application is to create an 3.1. Using a
|
- pool: size: core: 1 max:16 ---- ==== The following example also works: ==== [source,yaml] ---- kind: ConfigMap apiVersion: v1 metadata: name: demo data: custom-name.yaml: |
||
- pool: size: core: 1 max:16 ==== You can also configure Spring Boot applications differently depending on active profiles that are merged together when the `ConfigMap` is read. You can provide different property values for different profiles by using an `application.properties` or `application.yaml` property, specifying profile-specific values, each in their own document (indicated by the `---` sequence), as follows: ==== [source,yaml] kind: ConfigMap apiVersion: v1 metadata: name: demo data: application.yml: |
- greeting: message: Say Hello to the World farewell: message: Say Goodbye --- spring: profiles: development greeting: message: Say Hello to the Developers farewell: message: Say Goodbye to the Developers --- spring: profiles: production greeting: message: Say Hello to the Ops ---- ==== In the preceding case, the configuration loaded into your Spring Application with the ==== [source,yaml] ---- greeting: message: Say Hello to the Developers farewell: message: Say Goodbye to the Developers ---- ==== However, if the ==== [source,yaml] ---- greeting: message: Say Hello to the Ops farewell: message: Say Goodbye ---- ==== If both profiles are active, the property that appears last within the Another option is to create a different config map per profile and spring boot will automatically fetch it based on active profiles ==== [source,yaml] ---- kind: ConfigMap apiVersion: v1 metadata: name: demo data: application.yml: |
||
- greeting: message: Say Hello to the World farewell: message: Say Goodbye ==== ==== [source,yaml] kind: ConfigMap apiVersion: v1 metadata: name: demo-development data: application.yml: |
- spring: profiles: development greeting: message: Say Hello to the Developers farewell: message: Say Goodbye to the Developers ---- ==== ==== [source,yaml] ---- kind: ConfigMap apiVersion: v1 metadata: name: demo-production data: application.yml: |
| Name | Type | Default | Description
| spring.cloud.kubernetes.config.enabled
| Boolean
| true
| Enable ConfigMaps PropertySource
| spring.cloud.kubernetes.config.name
| String
| ${spring.application.name}
| Sets the name of ConfigMap
to look up
| spring.cloud.kubernetes.config.namespace
| String
| Client namespace | Sets the Kubernetes namespace where to lookup
| spring.cloud.kubernetes.config.paths
| List
| null
| Sets the paths where ConfigMap
instances are mounted
| spring.cloud.kubernetes.config.enableApi
| Boolean
| true
| Enable or disable consuming ConfigMap
instances through APIs
=== Secrets PropertySource Kubernetes has the notion of Secrets for storing
sensitive data such as passwords, OAuth tokens, and so on. This project provides integration with When enabled, the . Reading recursively from secrets mounts
. Named after the application (as defined by Note: By default, consuming Secrets through the API (points 2 and 3 above) is not enabled for security reasons. The permission 'list' on secrets allows clients to inspect secrets values in the specified namespace. Further, we recommend that containers share secrets through mounted volumes. If you enable consuming Secrets through the API, we recommend that you limit access to Secrets by using an authorization policy, such as RBAC. For more information about risks and best practices when consuming Secrets through the API refer to this doc. If the secrets are found, their data is made available to the application. Assume that we have a spring boot application named ==== [source] ---- kubectl create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd ---- ==== The preceding command would create the following secret (which you can see by using ==== [source,yaml] ---- apiVersion: v1 data: password: cDQ1NXcwcmQ= username: dXNlcg== kind: Secret metadata: creationTimestamp: 2017-07-04T09:15:57Z name: db-secret namespace: default resourceVersion: "357496" selfLink: /api/v1/namespaces/default/secrets/db-secret uid: 63c89263-6099-11e7-b3da-76d6186905a8 type: Opaque ---- ==== Note that the data contains Base64-encoded versions of the literal provided by the Your application can then use this secret — for example, by exporting the secret’s value as environment variables: ==== [source,yaml] ---- apiVersion: v1 kind: Deployment metadata: name: ${project.artifactId} spec: template: spec: containers: - env: - name: DB_USERNAME valueFrom: secretKeyRef: name: db-secret key: username - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: password ---- ==== You can select the Secrets to consume in a number of ways: . By listing the directories where secrets are mapped: + ==== [source,bash] ---- -Dspring.cloud.kubernetes.secrets.paths=/etc/secrets/db-secret,etc/secrets/postgresql ---- ==== + If you have all the secrets mapped to a common root, you can set them like: + ==== [source,bash] ---- -Dspring.cloud.kubernetes.secrets.paths=/etc/secrets ---- ==== . By setting a named secret: + ==== [source,bash] ---- -Dspring.cloud.kubernetes.secrets.name=db-secret ---- ==== . By defining a list of labels: + ==== [source,bash] ---- -Dspring.cloud.kubernetes.secrets.labels.broker=activemq -Dspring.cloud.kubernetes.secrets.labels.db=postgresql ---- ==== As the case with ==== [source,yaml] ---- spring: application: name: cloud-k8s-app cloud: kubernetes: secrets: name: default-name namespace: default-namespace sources: # Spring Cloud Kubernetes looks up a Secret named s1 in namespace default-namespace - name: s1 # Spring Cloud Kubernetes looks up a Secret named default-name in whatever namespace n2 - namespace: n2 # Spring Cloud Kubernetes looks up a Secret named s3 in namespace n3 - namespace: n3 name: s3 ---- ==== In the preceding example, if .Properties: [options="header,footer"] |
| Name | Type | Default | Description
| spring.cloud.kubernetes.secrets.enabled
| Boolean
| true
| Enable Secrets PropertySource
| spring.cloud.kubernetes.secrets.name
| String
| ${spring.application.name}
| Sets the name of the secret to look up
| spring.cloud.kubernetes.secrets.namespace
| String
| Client namespace | Sets the Kubernetes namespace where to look up
| spring.cloud.kubernetes.secrets.labels
| Map
| null
| Sets the labels used to lookup secrets
| spring.cloud.kubernetes.secrets.paths
| List
| null
| Sets the paths where secrets are mounted (example 1)
| spring.cloud.kubernetes.secrets.enableApi
| Boolean
| false
| Enables or disables consuming secrets through APIs (examples 2 and 3)
Notes: * The You can find an example of an application that uses secrets (though it has not been updated to use the new === WARNING: This functionality has been deprecated in the 2020.0 release. Please see the [spring-cloud-kubernetes-configuration-watcher] controller for an alternative way to achieve the same functionality. Some applications may need to detect changes on external property sources and update their internal status to reflect the new configuration.
The reload feature of Spring Cloud Kubernetes is able to trigger an application reload when a related By default, this feature is disabled. You can enable it by using the The following levels of reload are supported (by setting the * * * Assuming that the reload feature is enabled with default settings ( ==== [java, source] ---- @Configuration @ConfigurationProperties(prefix = "bean") public class MyConfig { private String message = "a message that can be changed live"; // getter and setters } ---- ==== To see that changes effectively happen, you can create another bean that prints the message periodically, as follows ==== [source,java] ---- @Component public class MyBean { @Autowired private MyConfig config; @Scheduled(fixedDelay = 5000) public void hello() { System.out.println("The message is: " + config.getMessage()); } } ---- ==== You can change the message printed by the application by using a ==== [source,yaml] ---- apiVersion: v1 kind: ConfigMap metadata: name: reload-example data: application.properties: |
- bean.message=Hello World! ---- ==== Any change to the property named The full example is available in The reload feature supports two operating modes:
* Event (default): Watches for changes in config maps or secrets by using the Kubernetes API (web socket).
Any event produces a re-check on the configuration and, in case of changes, a reload.
The .Properties: [options="header,footer"] |
| Name | Type | Default | Description
| spring.cloud.kubernetes.reload.enabled
| Boolean
| false
| Enables monitoring of property sources and configuration reload
| spring.cloud.kubernetes.reload.monitoring-config-maps
| Boolean
| true
| Allow monitoring changes in config maps
| spring.cloud.kubernetes.reload.monitoring-secrets
| Boolean
| false
| Allow monitoring changes in secrets
| spring.cloud.kubernetes.reload.strategy
| Enum
| refresh
| The strategy to use when firing a reload (refresh
, restart_context
, or shutdown
)
| spring.cloud.kubernetes.reload.mode
| Enum
| event
| Specifies how to listen for changes in property sources (event
or polling
)
| spring.cloud.kubernetes.reload.period
| Duration
| 15s
| The period for verifying changes when using the polling
strategy
Notes:
* You should not use properties under == Kubernetes Ecosystem Awareness All of the features described earlier in this guide work equally well, regardless of whether your application is running inside
Kubernetes. This is really helpful for development and troubleshooting.
From a development point of view, this lets you start your Spring Boot application and debug one
of the modules that is part of this project. You need not deploy it in Kubernetes,
as the code of the project relies on the
Fabric8 Kubernetes Java client, which is a fluent DSL that can
communicate by using To disable the integration with Kubernetes you can set |
yml}` (or the profile specific one) otherwise it should be in `application.{properties |
yml}` (or the profile specific one).
Also note that these properties: |
yml}` === Kubernetes Profile Autoconfiguration When the application runs as a pod inside Kubernetes, a Spring profile named === Istio Awareness When you include the The Istio awareness module uses == Pod Health Indicator Spring Boot uses The Kubernetes health indicator (which is part of the core module) exposes the following info: * Pod name, IP address, namespace, service account, node name, and its IP address * A flag that indicates whether the Spring Boot application is internal or external to Kubernetes == Info Contributor Spring Cloud Kubernetes includes an You can disable this |
yaml] == Leader Election <TBD> == LoadBalancer for Kubernetes This project includes Spring Cloud Load Balancer for load balancing based on Kubernetes Endpoints and provides implementation of load balancer based on Kubernetes Service. To include it to your project add the following dependency. ==== [source,xml] ---- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-kubernetes-fabric8-loadbalancer</artifactId> </dependency> ---- ==== To enable load balancing based on Kubernetes Service name use the following property. Then load balancer would try to call application using address, for example `service-a.default.svc.cluster.local ==== [source] ---- spring.cloud.kubernetes.loadbalancer.mode=SERVICE ---- ==== To enabled load balancing across all namespaces use the following property. Property from == Security Configurations Inside Kubernetes === Namespace Most of the components provided in this project need to know the namespace. For Kubernetes (1.3+), the namespace is made available to the pod as part of the service account secret and is automatically detected by the client. For earlier versions, it needs to be specified as an environment variable to the pod. A quick way to do this is as follows: ==== [source] ---- env: - name: "KUBERNETES_NAMESPACE" valueFrom: fieldRef: fieldPath: "metadata.namespace" ---- ==== === Service Account For distributions of Kubernetes that support more fine-grained role-based access within the cluster, you need to make sure a pod that runs with Depending on the requirements, you’ll need .Kubernetes Resource Permissions |
|Dependency | Resources
|spring-cloud-starter-kubernetes-fabric8 |pods, services, endpoints
|spring-cloud-starter-kubernetes-fabric8-config |configmaps, secrets
|spring-cloud-starter-kubernetes-client |pods, services, endpoints
|spring-cloud-starter-kubernetes-client-config |configmaps, secrets
For development purposes, you can add The following Role and RoleBinding are an example for namespaced permissions for the ==== [source,yaml] ---- kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: YOUR-NAME-SPACE name: namespace-reader rules: - apiGroups: ["", "extensions", "apps"] resources: ["configmaps", "pods", "services", "endpoints", "secrets"] verbs: ["get", "list", "watch"] --- kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: namespace-reader-binding namespace: YOUR-NAME-SPACE subjects: - kind: ServiceAccount name: default apiGroup: "" roleRef: kind: Role name: namespace-reader apiGroup: "" ---- ==== == Service Registry Implementation In Kubernetes service registration is controlled by the platform, the application itself does not control
registration as it may do in other platforms. For this reason using [spring-cloud-kubernetes-configuration-watcher] Spring Cloud Kubernetes Configuration Watcher Kubernetes provides the ability to mount a ConfigMap or Secret as a volume in the container of your application. When the contents of the ConfigMap or Secret changes, the mounted volume will be updated with those changes. However, Spring Boot will not automatically update those changes unless you restart the application. Spring Cloud
provides the ability refresh the application context without restarting the application by either hitting the
actuator endpoint To achieve this configuration refresh of a Spring Cloud app running on Kubernetes, you can deploy the Spring Cloud Kubernetes Configuration Watcher controller into your Kubernetes cluster. The application is published as a container and is available on Docker Hub. Spring Cloud Kubernetes Configuration Watcher can send refresh notifications to applications in two ways. 1. Over HTTP in which case the application being notified must of the Deployment YAML Below is a sample deployment YAML you can use to deploy the Kubernetes Configuration Watcher to Kubernetes. ==== [source,yaml] ---- --- apiVersion: v1 kind: List items: - apiVersion: v1 kind: Service metadata: labels: app: spring-cloud-kubernetes-configuration-watcher name: spring-cloud-kubernetes-configuration-watcher spec: ports: - name: http port: 8888 targetPort: 8888 selector: app: spring-cloud-kubernetes-configuration-watcher type: ClusterIP - apiVersion: v1 kind: ServiceAccount metadata: labels: app: spring-cloud-kubernetes-configuration-watcher name: spring-cloud-kubernetes-configuration-watcher - apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: app: spring-cloud-kubernetes-configuration-watcher name: spring-cloud-kubernetes-configuration-watcher:view roleRef: kind: Role apiGroup: rbac.authorization.k8s.io name: namespace-reader subjects: - kind: ServiceAccount name: spring-cloud-kubernetes-configuration-watcher - apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: default name: namespace-reader rules: - apiGroups: ["", "extensions", "apps"] resources: ["configmaps", "pods", "services", "endpoints", "secrets"] verbs: ["get", "list", "watch"] - apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-kubernetes-configuration-watcher-deployment spec: selector: matchLabels: app: spring-cloud-kubernetes-configuration-watcher template: metadata: labels: app: spring-cloud-kubernetes-configuration-watcher spec: serviceAccount: spring-cloud-kubernetes-configuration-watcher containers: - name: spring-cloud-kubernetes-configuration-watcher image: springcloud/spring-cloud-kubernetes-configuration-watcher:2.0.0-SNAPSHOT imagePullPolicy: IfNotPresent readinessProbe: httpGet: port: 8888 path: /actuator/health/readiness livenessProbe: httpGet: port: 8888 path: /actuator/health/liveness ports: - containerPort: 8888 ---- ==== The Service Account and associated Role Binding is important for Spring Cloud Kubernetes Configuration to work properly. The controller needs access to read data about ConfigMaps, Pods, Services, Endpoints and Secrets in the Kubernetes cluster. # Monitoring ConfigMaps and Secrets Spring Cloud Kubernetes Configuration Watcher will react to changes in ConfigMaps with a label of The labels Spring Cloud Kubernetes Configuration Watcher looks for on ConfigMaps and Secrets can be changed by setting
If a change is made to a ConfigMap or Secret with valid labels then Spring Cloud Kubernetes Configuration Watcher will take the name of the ConfigMap or Secret and send a notification to the application with that name. # HTTP Implementation The HTTP implementation is what is used by default. When this implementation is used Spring Cloud Kubernetes Configuration Watcher and a
change to a ConfigMap or Secret occurs then the HTTP implementation will use the Spring Cloud Kubernetes Discovery Client to fetch all
instances of the application which match the name of the ConfigMap or Secret and send an HTTP POST request to the application’s actuator
# Non-Default Management Port and Actuator Path If the application is using a non-default actuator path and/or using a different port for the management endpoints, the Kubernetes service for the application
can add an annotation called ==== [source,yaml] ---- apiVersion: v1 kind: Service metadata: labels: app: config-map-demo name: config-map-demo annotations: boot.spring.io/actuator: :9090/myactuator/home spec: ports: - name: http port: 8080 targetPort: 8080 selector: app: config-map-demo ---- ==== Another way you can choose to configure the actuator path and/or management port is by setting
Messaging Implementation The messaging implementation can be enabled by setting profile to either # Configuring RabbitMQ When the ==== [source,yaml] ---- spring: rabbitmq: username: user password: password host: rabbitmq ---- ==== # Configuring Kafka When the ==== [source,yaml] ---- spring: kafka: producer: bootstrap-servers: localhost:9092 ---- ==== == Examples Spring Cloud Kubernetes tries to make it transparent for your applications to consume Kubernetes Native Services by following the Spring Cloud interfaces. In your applications, you need to add the The following projects highlight the usage of these dependencies and demonstrate how you can use these libraries from any Spring Boot application: * Spring Cloud Kubernetes Examples: the ones located inside this repository. * Spring Cloud Kubernetes Full Example: Minions and Boss Minion Boss * Spring Cloud Kubernetes Full Example: SpringOne Platform Tickets Service * Spring Cloud Gateway with Spring Cloud Kubernetes Discovery and Config * Spring Boot Admin with Spring Cloud Kubernetes Discovery and Config == Other Resources This section lists other resources, such as presentations (slides) and videos about Spring Cloud Kubernetes. * S1P Spring Cloud on PKS * Spring Cloud, Docker, Kubernetes → London Java Community July 2018 Please feel free to submit other resources through pull requests to this repository. == Configuration properties To see the list of all Kubernetes related configuration properties please check the Appendix page. == Building :jdkversion: 1.7 === Basic Compile and Test To build the source you will need to install JDK {jdkversion}. Spring Cloud uses Maven for most build-related activities, and you should be able to get off the ground quite quickly by cloning the project you are interested in and typing ---- $ ./mvnw install ---- NOTE: You can also install Maven (>=3.3.3) yourself and run the NOTE: Be aware that you might need to increase the amount of memory
available to Maven by setting a For hints on how to build the project look in The projects that require middleware generally include a
NOTE: If all else fails, build with the command from === Documentation The spring-cloud-build module has a "docs" profile, and if you switch
that on it will try to build asciidoc sources from
=== Working with the code If you don’t have an IDE preference we would recommend that you use Spring Tools Suite or Eclipse when working with the code. We use the m2eclipse eclipse plugin for maven support. Other IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better. ==== Activate the Spring Maven profile Spring Cloud projects require the 'spring' Maven profile to be activated to resolve the spring milestone and snapshot repositories. Use your preferred IDE to set this profile to be active, or you may experience build errors. ==== Importing into eclipse with m2eclipse We recommend the m2eclipse eclipse plugin when working with eclipse. If you don’t already have m2eclipse installed it is available from the "eclipse marketplace". NOTE: Older versions of m2e do not support Maven 3.3, so once the
projects are imported into Eclipse you will also need to tell
m2eclipse to use the right profile for the projects. If you
see many different errors related to the POMs in the projects, check
that you have an up to date installation. If you can’t upgrade m2e,
add the "spring" profile to your ==== Importing into eclipse without m2eclipse If you prefer not to use m2eclipse you can generate eclipse project metadata using the following command: [indent=0] ---- $ ./mvnw eclipse:eclipse ---- The generated eclipse projects can be imported by selecting == Contributing :spring-cloud-build-branch: master Spring Cloud is released under the non-restrictive Apache 2.0 license, and follows a very standard Github development process, using Github tracker for issues and merging pull requests into master. If you want to contribute even something trivial please do not hesitate, but follow the guidelines below. === Sign the Contributor License Agreement Before we accept a non-trivial patch or pull request we will need you to sign the Contributor License Agreement. Signing the contributor’s agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests. === Code of Conduct This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected]. === Code Conventions and Housekeeping None of these is essential for a pull request, but they will all help. They can also be added after the original pull request but before a merge. * Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
=== Checkstyle Spring Cloud Build comes with a set of checkstyle rules. You can find them in the .spring-cloud-build-tools/ ---- └── src ├── checkstyle │ └── checkstyle-suppressions.xml <3> └── main └── resources ├── checkstyle-header.txt <2> └── checkstyle.xml <1> ---- <1> Default Checkstyle rules <2> File header setup <3> Default suppression rules ==== Checkstyle configuration Checkstyle rules are disabled by default. To add checkstyle to your project just define the following properties and plugins. .pom.xml ---- <properties> <maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError> <1> <maven-checkstyle-plugin.failsOnViolation>true </maven-checkstyle-plugin.failsOnViolation> <2> <maven-checkstyle-plugin.includeTestSourceDirectory>true </maven-checkstyle-plugin.includeTestSourceDirectory> <3> </properties> <build> <plugins> <plugin> <4> <groupId>io.spring.javaformat</groupId> <artifactId>spring-javaformat-maven-plugin</artifactId> </plugin> <plugin> <5> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> </plugin> </plugins> <reporting> <plugins> <plugin> <5> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> </plugin> </plugins> </reporting> </build> ---- <1> Fails the build upon Checkstyle errors <2> Fails the build upon Checkstyle violations <3> Checkstyle analyzes also the test sources <4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules <5> Add checkstyle plugin to your build and reporting phases If you need to suppress some rules (e.g. line length needs to be longer), then it’s enough for you to define a file under .projectRoot/src/checkstyle/checkstyle-suppresions.xml ---- <?xml version="1.0"?> <!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "https://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> <suppressions> <suppress files=".*ConfigServerApplication\.java" checks="HideUtilityClassConstructor"/> <suppress files=".*ConfigClientWatch\.java" checks="LineLengthCheck"/> </suppressions> ---- It’s advisable to copy the
=== IDE setup ==== Intellij IDEA In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. The following files can be found in the Spring Cloud Build project. .spring-cloud-build-tools/ ---- └── src ├── checkstyle │ └── checkstyle-suppressions.xml <3> └── main └── resources ├── checkstyle-header.txt <2> ├── checkstyle.xml <1> └── intellij ├── Intellij_Project_Defaults.xml <4> └── Intellij_Spring_Boot_Java_Conventions.xml <5> ---- <1> Default Checkstyle rules <2> File header setup <3> Default suppression rules <4> Project defaults for Intellij that apply most of Checkstyle rules <5> Project style conventions for Intellij that apply most of Checkstyle rules .Code style image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style] Go to .Inspection profiles image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style] Go to .Checkstyle To have Intellij work with Checkstyle, you have to install the image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle] Go to - IMPORTANT: Remember to set the |