2017-04-12 69 views
0

我想带弹簧的云配置,为1.3.0.release版本,我开始与成功Spring配置错误对/ env的

curl localhost:8888/foo/development returns 

{"name":"foo","profiles":["development"],"label":null,"version":null,"state":null,"propertySources":[{"name":"https://github.com/spring-cloud-samples/config-repo/foo-development.properties","source":{"bar":"spam","foo":"from foo development"}},{"name":"https://github.com/spring-cloud-samples/config-repo/foo.properties","source":{"democonfigclient.message":"hello spring io","foo":"from foo props"}},{"name":"https://github.com/spring-cloud-samples/config-repo/application.yml","source":{"info.description":"Spring Cloud Samples","info.url":"https://github.com/spring-cloud-samples","eureka.client.serviceUrl.defaultZone":"http://localhost:8761/eureka/","foo":"baz"}}]} 

我试着用下面

的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>org.springframework</groupId> 
    <artifactId>gs-spring-config</artifactId> 
    <version>0.1.0</version> 

    <parent> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-parent</artifactId> 
     <version>Brixton.RELEASE</version> 
    </parent> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-config</artifactId> 
     </dependency> 
     <!-- tag::tests[] --> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <!-- end::tests[] --> 
    </dependencies> 

    <properties> 
     <java.version>1.8</java.version> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <executions> 
        <execution> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

然后我用MVN春天启动:运行时,它总是停

如果我添加的依赖

org.springframework.boot 弹簧引导启动的Web

它可以启动,但是当我访问本地主机:8080/ENV,它总是返回404,有什么遗漏吗?

Hello.java 

    package hello; 

    import org.springframework.web.bind.annotation.RestController; 
    import org.springframework.web.bind.annotation.RequestMapping; 

    @RestController 
    public class HelloController { 

     @RequestMapping("/") 
     public String index() { 
      return "Hello World"; 
     } 

    } 
+0

包括'弹簧引导起动actuator'作为一个依赖。 –

+0

日志中是否有任何错误消息? – reos

回答

1

正如在评论中提及,包括:

<dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-actuator</artifactId> 
    </dependency>