- intellij idea
- tomcat
- jar 8
创立spring boot 空我的项目
new->project
next->实现
配置pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.enashop</groupId> <artifactId>b2c</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>b2c</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud.version>Dalston<em style="color:transparent">来源[email protected]搞@^&代*@码网</em>.RELEASE</spring-cloud.version> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter</artifactId> <version>2.2.4.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <version>2.2.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
注:“spring-cloud-starter-eureka-server”曾经过期,改为“spring-cloud-starter-netflix-eureka-server”
配置 application.properties
spring.application.name=spring-cloud-eureka server.port=1010 #示意是否将本人注册到Eureka Server eureka.client.register-with-eureka=false #示意是否从Eureka Server获取注册信息 eureka.client.fetch-registry=false #设置与Eureka Server交互的地址,查问服务和注册服务都须要依赖这个地址 eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
启动类增加@EnableEurekaServer
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class B2cApplication { public static void main(String[] args) { SpringApplication.run(B2cApplication.class, args); } }
end…