Para quem fez tudo certo e mesmo assim o microservice nao é registrado no eureka e nao é informado nenhum erro provavelmente sao as depreciaçoes das importaçoes.
Segue importançoes e Anotaçloes funcionais ate esta data.
Do service :
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
public class PagamentoApplication {
public static void main(String[] args) {
SpringApplication.run(PagamentoApplication.class, args);
}
}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/alura-microservices?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=123456789
spring.jpa.show-sql=true
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
spring.application.name=pagamentos-ms
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>4.1.0</version>
</dependency>
Do eureka
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class ServerApplication {
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
}
}
server.port=8761
spring.application.name=server
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<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>