环境:springboot 2.0.0 + springcloud Finchley.M9
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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>net.common</groupId> <artifactId>eureka-server</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>eureka-server</name> <description>基本web</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</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>Finchley.M9</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </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> <repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>repository.springframework.maven.release</id> <name>Spring Framework Maven Release Repository</name> <url>http://maven.springframework.org/milestone/</url> </repository> <repository> <id>org.springframework</id> <url> http://maven.springframework.org/snapshot</url> </repository> <repository> <id>spring-milestone</id> <name>Spring Maven MILESTONE Repository</name> <url>http://repo.spring.io/libs-milestone</url> </repository> <repository> <id>spring-release</id> <name>Spring Maven RELEASE Repository</name> <url>http://repo.spring.io/libs-release</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
启动类:EurekaServerApplication.java
package net.common.util.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @EnableEurekaServer @SpringBootApplication public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } }
启动过程中会报错,说什么文件找不到,例如我的是:
……./WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
执行mvn package 报错:
[ERROR] 读取D:appmaven epositoryorgapache omcatembed omcat-embed-core8.5.28 omcat-embed-core-8.5.28.jar时出错; invalid LOC header (bad signature) [ERROR] 读取D:appmaven epositoryorghibernatevalidatorhibernate-validator6.0.7.Finalhibernate-validator-6.0.7.Final.jar时出错; invalid CEN header (bad signature) [ERROR] 读取D:appmaven epositoryjavaxvalidationvalidation-api2.0.1.Finalvalidation-api-2.0.1.Final.jar时出错; invalid LOC header (bad signature) [ERROR] 读取D:appmaven epositoryorgjbossloggingjboss-logging3.3.2.Finaljboss-logging-3.3.2.Final.jar时出错; invalid LOC header (bad signature)
自己感觉下载的JAR有问题,把所有报错的JAR全部删除,还有org.springframework下面的。
重新启动,一切OK。