2015-11-05 86 views
1

我有一个样品尤里卡服务器项目,运行时无论是在的IntelliJ,或者用“MVN春季启动:运行”工作正常。然而,直接与 “Java的罐子尤里卡服务器-1.0-SNAPSHOT.jar” 运行尤伯杯罐子的时候,我发现了以下堆栈跟踪:春云尤里卡:工作与Maven和IDE,但不作为尤伯杯罐子

2015-11-04 19:48:56.985 ERROR 138300 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.netflix.eureka.server.EurekaServerConfiguration]; nested exception is java.lang.IllegalStateException: Annotation @EnableDiscoveryClient found, but there are no implementations. Did you forget to include a starter? 
     at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:437) 
     at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:183) 
     at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) 
     at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) 
     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) 
     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) 
     at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) 
     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 
     at com.my.example.EurekaApplication.main(EurekaApplication.java:20) 
Caused by: java.lang.IllegalStateException: Annotation @EnableDiscoveryClient found, but there are no implementations. Did you forget to include a starter? 
     at org.springframework.cloud.util.SpringFactoryImportSelector.selectImports(SpringFactoryImportSelector.java:75) 
     at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:429) 
     ... 13 common frames omitted 

这里的POM文件:

<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.my.example</groupId> 
    <artifactId>eureka-server</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>eureka-server</name> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <java.version>1.8</java.version> 
    <start-class>com.my.example.EurekaApplication</start-class> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-eureka-server</artifactId> 
     <version>1.0.3.RELEASE</version> 
     <exclusions> 
     <exclusion> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-servlet</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-server</artifactId> 
     </exclusion> 
     </exclusions> 
    </dependency> 
    <!-- spring-cloud-starter-eureka-server 1.0.3 pulls conflicting jersey versions, 
    so we add 1.11 below and remove 1.13 in exclusions above --> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-servlet</artifactId> 
     <version>1.11</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-server</artifactId> 
     <version>1.11</version> 
    </dependency> 

    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <version>1.2.4.RELEASE</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.3</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-shade-plugin</artifactId> 
     <version>2.3</version> 
     <executions> 
      <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>shade</goal> 
      </goals> 
      <configuration> 
       <transformers> 
       <transformer 
         implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
        <mainClass>${start-class}</mainClass> 
       </transformer> 
       </transformers> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-maven-plugin</artifactId> 
     <version>1.2.4.RELEASE</version> 
     <configuration> 
      <mainClass>${start-class}</mainClass> 
      <addResources>true</addResources> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 


</project> 

所以我有一个弹簧云起动尤里卡服务器启动的依赖,再加上我没有@EnableDiscoveryClient标注在项目的任何地方。

这里是整个项目唯一的.java文件:

@SpringBootApplication 
@EnableEurekaServer 
public class EurekaApplication 
{  
    public static void main(String[] args) { 
     SpringApplication.run(EurekaApplication.class, args);; 
    } 
} 

这里是application.properties文件:

server.port=8761 
eureka.client.registerWithEureka: false 
eureka.client.fetchRegistry: false 
eureka.server.waitTimeInMsWhenSyncEmpty: 0 

预先感谢您!

+0

你为什么使用阴影插件?春季启动插件应该为你做所有这些。 – spencergibb

回答

3

尤里卡不会工作与您指定的球衣版本(它不适合我)。

使用http://start.spring.io生成启动项目。

这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>com.my.example</groupId> 
    <artifactId>eureka-server</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>eureka-server</name> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.2.7.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-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-starter-parent</artifactId> 
       <version>Angel.SR3</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> 
+0

谢谢斯宾塞,但这并没有帮助(相同的问题)。 1.0.3是最新的稳定版本吗?哪一种弹簧启动版本应该与1.0.3一起使用? – Turar

+0

谢谢斯宾塞。我没有得到它的工作在本周早些时候 - 我只是缺少弹簧引导Maven的插件内的“改头换面”的执行目标,是的,我也摆脱了遮阳插件。但是,你的版本更清洁,也有效。非常感谢您的帮助! – Turar

+0

谢谢你斯宾塞!它效果很好。只是一个评论(关于你的建议),我真的认为这是一个伟大的想法(使用http://start.spring.io上手的基础上,至少,pom.xml中,等等),但是,可惜的是我做到了,希望一切都能正常工作,事实上并没有......这是另一个错误,但它没有奏效。无论如何,感谢您分享您的经验,确实您的POM运作良好。 –

相关问题