Spring Boot & Spring Cloud & Nacos 版本搭配

一个有效的 Spring Boot & Spring Cloud & Spring Cloud Alibaba Nacos 搭配

<parent>
	<groupId>org.springframework.bootgroupId>
	<artifactId>spring-boot-starter-parentartifactId>
	<version>2.2.5.RELEASEversion>
	<relativePath />
parent>

<dependencyManagement>
	
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloudgroupId>
			<artifactId>spring-cloud-dependenciesartifactId>
			<version>Hoxton.SR12version>
			<type>pomtype>
			<scope>importscope>
		dependency>
	dependencies>
dependencyManagement>

<dependencies>
	
	<dependency>
		<groupId>org.springframework.cloudgroupId>
		<artifactId>spring-cloud-starter-bootstrapartifactId>
		<version>3.0.3version>
	dependency>
	
	<dependency>
		<groupId>com.alibaba.cloudgroupId>
		<artifactId>spring-cloud-starter-alibaba-nacos-configartifactId>
		<version>2021.1version>
	dependency>
	<dependency>
		<groupId>com.alibaba.cloudgroupId>
		<artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
		<version>2021.1version>
	dependency>
dependencies>

Spring Boot内嵌tomcat, 是通过其父pom文件中引入相关依赖实现的,但有时候父pom文件中的依赖并不生效,需要手动引入tomcat依赖项实现:

<dependency>
	<groupId>org.apache.tomcat.embedgroupId>
	<artifactId>tomcat-embed-coreartifactId>
	<version>9.0.62version>
dependency>

否则引入如下类时会报错:

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

你可能感兴趣的:(SpingBoot,SpringCloud,spring,spring,cloud,java)