小编Anz*_*zar的帖子

Spring Cloud Config 客户端未从配置服务器加载值

我在尝试运行 Spring Cloud Config Client 时遇到以下问题:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'DATABASE_NAME' in string value "${DATABASE_NAME}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204
Run Code Online (Sandbox Code Playgroud)

我在POM.xml中的依赖如下:

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

<dependencyManagement>
    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config</artifactId>
            <version>1.1.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Brixton.SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>

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

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

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

</dependencies>
Run Code Online (Sandbox Code Playgroud)

bootstrap.yml …

maven spring-boot spring-cloud-config

8
推荐指数
2
解决办法
9226
查看次数

使用 Groovy 解组 JAXB

我正在尝试为以下 xml 创建模型类:

<Response>
    <Success>N</Success>
    <Errors>
        <Error>
            <Number>29002</Number>
            <Message>A key field was missing from the control xml</Message>
        </Error>
        <Error>
            <Number>29004</Number>
            <Message>Unable to accept messages at this time</Message>
        </Error>
    </Errors>
</Response>
Run Code Online (Sandbox Code Playgroud)

这是我的 Response.class

@XmlRootElement (name="Response")
@XmlAccessorType( XmlAccessType.FIELD )
class Response {

  @XmlElement(name="Success")
  private String success

  @XmlElement(name="Errors")
  private Errors errors

  public String getSuccess() {
    return success
  }

  public Errors getErrors() {
    return errors;
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的 Errors.class

@XmlRootElement(name="Errors")
@XmlAccessorType(XmlAccessType.FIELD)
class Errors {

  public Errors() {
    errorList = new ArrayList<Error>()
  }

  @XmlElement(name = …
Run Code Online (Sandbox Code Playgroud)

xml groovy jaxb unmarshalling

2
推荐指数
1
解决办法
1991
查看次数