我有一些字符串,里面有各种不同的表情符号/图像/符号.
并非所有字符串都是英文的 - 其中一些字符串是其他非拉丁语言,例如:
? railway??
? Cats and dogs
I'm on
Apples ?
? Vi sign
? I'm the king ?
Corée ? du Nord ? (French)
gjør at både ?? (Norwegian)
Star me ?
Star ? once more
??? ? (Chinese)
???????? ? (Greek)
another ? sign ?
?????? ?????? ? (Belarus)
? ??? ?????? ? (Hindi)
? ? ? ? Let's get together ?. We shall meet at 12/10/2018 10:00 AM at Tony's.?
Run Code Online (Sandbox Code Playgroud)
......还有更多这些.
我想摆脱所有这些标志/图像,只保留不同语言的字母(和标点符号).
我尝试使用EmojiParser库 …
我正在我的 Spring Boot 应用程序中进行集成测试。该应用程序需要使用 Redis。
在开发阶段,我有一个应用程序连接到的本地 Redis 容器。
对于集成测试,我使用testcontainers,并且我还遵循了他们如何使用 Redis 容器的示例。
在某些时候,我了解到只有当开发容器启动并运行时测试才能正确运行。如果它宕机了,那么集成测试就会失败,因为它们无法到达 Redis。
所以集成测试类看起来像这样:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SharkApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(locations = "classpath:application-integrationtests.yml")
@AutoConfigureMockMvc
public class SharkIntegrationTest {
static GenericContainer redis = new GenericContainer("redis:3.0.6")
.withExposedPorts(6379);
@BeforeClass
public static void before(){
redis.start();
}
@AfterClass
public static void after(){
redis.stop();
}
...
Run Code Online (Sandbox Code Playgroud)
运行测试时,我可以在日志中看到以下内容:
14:36:24.372 [main] DEBUG [redis:3.0.6] - Starting container: redis:3.0.6
14:36:24.372 [main] DEBUG [redis:3.0.6] - Trying to start container:
redis:3.0.6
14:36:24.373 [main] DEBUG [redis:3.0.6] - Trying …Run Code Online (Sandbox Code Playgroud) 我试图在我Mock的测试中使用一个类并收到此错误:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.example.Car.
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 1.8
JVM vendor name : Oracle Corporation
JVM vendor version : 25.161-b12
JVM name : Java HotSpot(TM) Client VM
JVM version : 1.8.0_161-b12
JVM info : mixed mode, sharing
OS name : Windows 10
OS version : 10.0
Underlying exception : java.lang.IllegalArgumentException: Could not …Run Code Online (Sandbox Code Playgroud) 我有一个Spring Boot尝试从本地Kafka主题读取的应用程序。
应用程序开始旋转,暂停 2 分钟并抛出以下错误:
19-11-10 14:49:24.700 INFO 20476 --- [ restartedMain] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1573390164696
2019-11-10 14:51:24.793 WARN 20476 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is java.lang.IllegalStateException: Topic(s) [XYZ] is/are not present and missingTopicsFatal is true
2019-11-10 14:51:24.795 INFO 20476 --- [ restartedMain] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2019-11-10 14:51:24.796 INFO 20476 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的Spring Boot版本2.0.1.RELEASE与Swagger集成 .
从这篇博文中 看来,通过添加两个Maven依赖项似乎很容易,一切都应该有效.
所以我在pom中添加了以下依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
并创建了SwaggerConfigbean:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
return docket;
}
}
Run Code Online (Sandbox Code Playgroud)
在属性文件中,我在尝试使其工作期间最终得到了这3个条目:
spring.application.name=cat-service
management.server.servlet.context-path=/cat-service
server.servlet.contextPath=/cat-service
Run Code Online (Sandbox Code Playgroud)
但最后,访问时
http://localhost:8080/cat-service/api/v2/api-docs
或UI页面
http://localhost:8080/cat-service/swagger-ui.html
我收到一个page not found错误.
我在swagger github页面 和stackoverflow 中的这个问题中发现了这个问题 但是我无法改变我的404错误.
最近在面试一位Java开发者时,遇到了一个关于spring注解的问题:
spring中编译时注解和运行时注解有什么区别?
有这样的概念吗?
如果有答案,我们将不胜感激。
我正在学习elasticsearch并编写了几个简单的程序来插入、更新、删除数据。
我读过弹性搜索总是以json格式存储数据。
我查看了data我的elasticsearch安装中的“ ”文件夹,即使我做了一些插入操作,我也找不到任何json格式的文件。我可以看到一些带有.st扩展名的文件。
那么elasticsearch实际上将json格式的数据存储在哪里呢?
所以我的新Spring boot应用程序似乎忽略了application.yml文件中的属性......
我试图通过更新 application.yml 文件来覆盖默认服务器端口以包含
server:
port: 8952
Run Code Online (Sandbox Code Playgroud)
但应用程序在端口 8080 上启动
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
Run Code Online (Sandbox Code Playgroud)
我正在从 运行它Intellij。
application.yml 位置:
C:\myProject\src\main\resources\application.yml
Run Code Online (Sandbox Code Playgroud)
主要上课地点:
C:\myProject\src\main\java\com\example\MyApplication.java
Run Code Online (Sandbox Code Playgroud)
这是应用程序的配置窗口:
以下是 pom 中的相关部分:
<properties>
<spring-boot-version>2.2.0.RELEASE</spring-boot-version>
<java.version>1.8</java.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-version}</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这一定是我在这里遗漏的一件非常小的事情,因为在我的其他应用程序中它正在按预期工作
我有一个Spring Boot带有集成测试的应用程序,该测试使用testContainers.
直到最近,我还在使用 Docker Desktop,并且能够轻松地从 Intellij 或 CLI 中运行测试。
最近我将我的 Windows 机器更改为Rancher 桌面。
现在,当尝试运行集成测试时,gradle integrationTest我收到此错误:
原因:java.lang.IllegalStateException:之前尝试查找 Docker 环境失败。不会重试。请查看日志并检查配置 org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:109) org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:136) org.testcontainers.DockerClientFactory.client(DockerClientFactory.java) :178)在org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)在org.testcontainers.LazyDockerClient.authConfig(LazyDockerClient.java:12)在org.testcontainers.containers.GenericContainer.start(GenericContainer.java:310)
Intellij 或 Rancher 或 Windows 中是否需要额外的配置才能使其工作?
我的 Java 和 Spring Boot 应用程序集成测试使用testContainers并且我在 Windows 计算机上使用Podman 。
当尝试运行集成测试时,我收到此权限错误:
Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
.....
Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"cause":"permission denied","message":"container create: statfs /var/run/docker.sock: permission denied","response":500}
Run Code Online (Sandbox Code Playgroud)
所有集成测试都失败了。
我需要向 Podman 提供特定的权限命令吗?
java ×6
spring-boot ×3
apache-kafka ×1
containers ×1
docker ×1
emoji ×1
junit ×1
mockito ×1
permissions ×1
podman ×1
rancher ×1
redis ×1
spring ×1
string ×1
swagger ×1