【发布时间】:2020-04-05 17:55:18
【问题描述】:
我正在尝试在我的 Spring Boot (Maven) 应用程序中使用 consul 添加“服务发现”,但无法使用 @EnableDiscoveryClient。因为,我是 Intellij 的新手,所以我不确定我错过了什么。
添加了 pom。
我做了以下事情:
- 在我的 pom.xml 中添加了 consul 依赖项
-
<?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> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.mancala</groupId> <artifactId>MancalaFrontend</artifactId> <version>0.0.1-SNAPSHOT</version> <name>MancalaFrontend</name> <description>Front-end service for Mancala game.</description> <properties> <java.version>1.8</java.version> <vaadin.version>14.1.23</vaadin.version> </properties> <dependencies> <!-- Actuator --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Web Starter --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Consul --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-consul-discovery</artifactId> </dependency> <!-- Vaadin --> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-spring-boot-starter</artifactId> </dependency> <!-- Test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <!-- Vaadin Dependency Management--> <dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-bom</artifactId> <version>${vaadin.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>
【问题讨论】:
-
不要使用图片,最好使用发布的文本。此外,您的项目是否建立在普通命令行上?
-
我不确定我是否完全理解“在普通命令行上构建”
-
您是否尝试过通过
mvn clean package在普通控制台中构建? -
你是怎么做到的? @khmarbaise
-
没有神器版本。您是否为 spring-cloud 添加了依赖管理?如果您需要更多帮助,请分享您的整个 pom。
标签: spring-boot maven consul service-discovery