Follow below example. Added something you not have on your pom.xml please ignore the comment; when you are done, please check your type, this is case sensitive. My example using server. Hope work on related issue
<properties>
<!-- using java 17 -->
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<!--optional(?)-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- the main problem here(?)-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
info:
file|Project Structure -> project -> SDK: SDK corretto-17
during process check the color of your code example:
//todo: it goes red.. must have different color
@EnableEurekaServer
It supposed to be red. If red is fine.. don't added this line
//todo: added by importing
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
you must reload the maven (it take times.. for me take 2 minutes) in order to download what you needed. Then put your cursor on the red code until pop-up
cannot resolve symbol Bla bla
then click import the class.
Result you should have
package com.***.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//todo: added by importing
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
//todo added application and server
@SpringBootApplication
@EnableEurekaServer
//just example name
public class EurekaServerApplication {
//todo: make main
}
If nothing happen, then you should follow some suggestion
- downgrade your script. Were Bad idea
- downgrade your java. Still bad idea, I'm using 17, while new java version on this moment are 19.
- check the version on your code. When I make this, there is version below the on the example and my working code, the line not used it. the version said on the pom.xml (parent) were
<spring.cloud-version>2020.0.3</spring.cloud-version>
If you find the current version not worked. Please added comment for it.
disclamer: using Intellij Idea.
source: youtube
with keyword #servicediscovery #microservices #amigoscode
For compare purpose I'm posting root pom.xml for refences only
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.***code</groupId>
<artifactId>***services</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>***services</name>
<url>http://www.***services.com</url>
<modules>
<!--something here not wanted to share-->
<module>eureka-server</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring.boot.maven.plugin.version>2.5.7</spring.boot.maven.plugin.version>
<spring.boot.dependency.version >2.5.7</spring.boot.dependency.version>
<spring.cloud-version>2020.0.3</spring.cloud-version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.dependency.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<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>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>