小编Jon*_*ham的帖子

Spring Boot / actuator返回404找不到

我正在使用Spring Boot 2.1.4.RELEASE,当前正在尝试访问http:// localhost:8080 / actuator,但找不到404。我不确定我在这里做错了什么。以下是我的pom依赖关系-

 <?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.dir</groupId>
    <artifactId>api</artifactId>
    <version>2.4.0</version>
    <packaging>jar</packaging>

    <name>Search</name>
    <description>Search</description>

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

    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>repo1.releases</name>
            <url>http://www.something.com</url>
        </repository>
        <snapshotRepository>
            <id>Snapshots</id>
            <name>repo1.com</name>
            <url>http://repo1.com/artifactory/Snapshots</url>
        </snapshotRepository>
    </distributionManagement>


    <properties>
        <!--These two should be in all ParentPOMs -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Keep this version in sync with the pom's version ignoring "-SNAPSHOT" -->
        <applicationVersion>1.0.0</applicationVersion>
        <elasticsearch.version>5.2.0</elasticsearch.version>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId> …
Run Code Online (Sandbox Code Playgroud)

spring spring-boot spring-boot-actuator

5
推荐指数
6
解决办法
1993
查看次数

我如何在 jmeter 中使用 beanshell 预处理器删除空参数

我正在尝试读取包含超过 500 行的 csv 文件,每一行都将作为对 API 的请求。现在我的问题是一些参数有空字符串,我想设置一个条件,以防参数返回空字符串,然后在点击 API 之前从请求正文中删除该参数

下面是我的json

{
  "body": {
    "Id1": "${Id1}",
    "addressId": "${addressId}",
    "languageCode": "${languageCode}",
    "tempId": "${tempId}"
}
Run Code Online (Sandbox Code Playgroud)

现在在阅读 csv 后,我在我的请求正文中得到以下值

{
  "body": {
    "Id1": "1",
    "addressId": "1233",
    "languageCode": "E",
    "tempId": ""
}
Run Code Online (Sandbox Code Playgroud)

如您所见, tempId 具有空字符串。现在使用 bean-shell 预处理器我试图删除它但没有运气

Object requestBody = sampler.getArguments().getArgument(0).getValue();

if (requestBody.get("tempId").equals("")){
    sampler.getArguments.removeArgument("tempId");
}
Run Code Online (Sandbox Code Playgroud)

当我查看结果树时,我没有看到 tempId 从请求中删除。我将不胜感激任何帮助

jmeter beanshell

5
推荐指数
1
解决办法
889
查看次数

处理字符串的StringIndexOutOfBoundsException

try {
    string = scan.nextLine().charAt(0);
} catch(StringIndexOutOfBoundsException siobe){
    System.out.println("invalid input");
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用此代码来处理从文本文件中获取的字符串的异常。但是我得到一个错误,说尝试将实际的字符串声明更改为字符。我不确定该如何处理?

java

4
推荐指数
1
解决办法
9049
查看次数

如何查明key是否存在于cacheManager中(org.springframework.cache.CacheManager)

有没有办法查看cacheManager(org.springframework.cache.CacheManager)中是否存在特定的键,因为我无法找到一种方法来做到这一点,因为没有containsKey选项。如果有人可以向我展示一种检查缓存管理器中是否存在密钥的方法,我将不胜感激。以下是我迄今为止尝试过的一些事情 -

Cache cache=null;
for (String name : cacheManager.getCacheNames()) {
    cache=cacheManager.getCache(name);
    System.out.println("-------------->"+cache.get("dummyCache").get()); //this will give me null pointer exception as there is no dummyCache 
    }
Run Code Online (Sandbox Code Playgroud)

我想添加 if/else 检查以查看dummyCache缓存中是否存在密钥

caching infinispan spring-boot

3
推荐指数
1
解决办法
1万
查看次数

如何从数组中删除空元素

我正在尝试删除空元素,即数组中的双引号,但我不确定如何迭代 json 数组。下面是我的 json

{
  "body": {
   "newId":"value1"
  },
  "header": {
    "appId": "someVal",
    "pricingSchedule": [
      "price1",
      "price2",
      "price3",
      "",
      "",
      ""
    ]
  },
  "trail": {

    "pageSize": "50"
  }
}
Run Code Online (Sandbox Code Playgroud)

我想要做的是,header我想迭代pricingSchedule数组并删除空元素,如果数组中没有元素,那么我只想保留空数组而不是删除它。

下面是我尝试的代码 -

def request = new groovy.json.JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())

def newRequest = evaluate(request.inspect())


request.body.each { entry ->
    if (entry.getValue().equals('') || entry.getValue().equals([''])) {
        newRequest.body.remove(entry.getKey())
    }
}


request.header.each{ entry ->

//  String key=entry.getKey().equals("pricingSchedule")


    entry.getKey().equals("pricingSchedule").each{ entry1 ->

        log.info(entry1) //This does not print anything and gives me error

        }

}


def arguments …
Run Code Online (Sandbox Code Playgroud)

groovy

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

Infinispan 缓存放置无法循环运行

我正在使用嵌入式缓存管理器,我试图将缓存中的条目放入 for 循环中,但是当下一个请求被触发时,我看到缓存为空。以下是我的实现 -

EmbeddedCacheManager manager=null;
    {
        try {
            manager = new DefaultCacheManager("src/main/resources/infinispan.xml");


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    Cache cache=manager.getCache();



for (JsonElement jsonElement : jsonArray)
            {
                 id=jsonElement.getAsJsonObject().get("_id").getAsString();
                  id1= id.replace("-","");
                JsonObject source = jsonElement.getAsJsonObject().getAsJsonObject("_src");
                String jsonString = source.toString();


                Dummy dummy = new Gson().fromJson(jsonString, Dummy.class);



                if(cache.get(id1)!=null){
                    retVal.add((Dummy) cache.get(id1));
                    System.out.println("This is cached !");
                }else {
                    cache.put(id1,dummy);
                    retVal.add(dummy);
                    System.out.println("This is not cached");
                }

            }
Run Code Online (Sandbox Code Playgroud)

caching infinispan spring-boot

0
推荐指数
1
解决办法
187
查看次数

返回bool的函数数组

我有这些布尔函数,我正在单独编写,我正在考虑创建一个数组,然后使用循环来遍历它们中的每一个.下面是我想要放在数组中的各个函数.

bool A(void);
bool E(void);
bool O(void);
bool P(void);
bool U(void);
bool I(void);
bool C(void);
bool L(void);
bool D(void);
Run Code Online (Sandbox Code Playgroud)

我可以这样做吗?

c++ arrays function

-1
推荐指数
1
解决办法
103
查看次数