我在 quarkus application.properties 中配置了一个值
skipvaluecheck=true
Run Code Online (Sandbox Code Playgroud)
现在,每当我想要执行测试时,我都希望将此值设置为 false 而不是 true。但我不想更改application.properties,因为它会影响最新的应用程序部署。我只是希望我的测试以 false 值执行,以便我的测试覆盖范围在声纳中变为绿色。
从java代码中,我通过下面的操作获取这个值
ConfigProvider.getConfig().getValue("skipvaluecheck", Boolean.class);
Run Code Online (Sandbox Code Playgroud)
Sprint boot 中已经存在类似的东西,我很好奇 quarkus 中是否也存在这样的东西
我一直application.properties在Spring应用程序中使用文件.但最近我遇到了application.yaml文件.这三者之间的优先顺序是什么,并且使用个人的优势(如果有的话).
我知道这可能是个愚蠢的问题.但我对他们的用法感到困惑.
yaml command-line-arguments spring-boot intellij-idea-2016 application.properties
我想使用application.properties文件中的值,以便在另一个类的方法中传递它.问题是值总是返回NULL.可能是什么问题呢?提前致谢.
application.properties
filesystem.directory=temp
Run Code Online (Sandbox Code Playgroud)
FileSystem.java
@Value("${filesystem.directory}")
private static String directory;
Run Code Online (Sandbox Code Playgroud) 我已经搜索了高低,但仍然无法找到这个非常烦人的问题的简单答案,
我遵循了这个很棒的指南: 带有多服务应用程序的 JWT 一切都很好,但在指南的最后,我们建议创建一个 config-service(module) ,我已经完成了。
问题是我无法覆盖 JwtConfig 类的默认配置
项目结构如下:
-config-service
| JwtConfig.java
\
| resources
\
| jwtConfig.properties
-other-service (add dependency in the pom file of the config-service)
|
someOtherclass.java (import the JwtConfig class & using @Bean to initialize )
Run Code Online (Sandbox Code Playgroud)
JwtConfig 类:
/*all the imports*/
@PropertySource(value = "classpath:jwtConfig.properties")
public class JwtConfig {
@Value("${security.jwt.uri:/auth/**}")
private String Uri;
@Value("${security.jwt.header:Authorization}")
private String header;
@Value("${security.jwt.prefix:Bearer }")
private String prefix;
@Value("${security.jwt.expiration:#{24*60*60}}")
private int expiration;
@Value("${security.jwt.secret:JwtSecretKey}")
private String secret;
//getters
Run Code Online (Sandbox Code Playgroud)
someOtherclass.java:
/*imports*/
@Configuration
@EnableWebSecurity …Run Code Online (Sandbox Code Playgroud) maven multi-module spring-boot application.properties java-11
我的 application.yml 文件如下。如何将其转换为 application.properties 我正在尝试,但如何在同一个文件中写入多个属性。它给了我重复的克里错误。
---
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
---
spring:
profiles: peer2
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用junit对spring-boot应用程序进行单元测试.我已将application-test.properties放在src/test/resources下.我有一个ApplicationConfiguration类,它读取application.properties.
我的测试类看起来像这样
@RunWith(SpringRunner.class)
@SpringBootTest(classes=ApplicationConfiguration.class)
@TestPropertySource(locations = "classpath:application-test.properties")
@ActiveProfiles("test")
public class TestBuilders {
@Autowired
private ApplicationConfiguration properties;
Run Code Online (Sandbox Code Playgroud)
当我尝试读取属性时,它始终为null.
我的ApplicationConfiguration类看起来像这样
@Configuration
@ConfigurationProperties
@PropertySources({
@PropertySource("classpath:application.properties"),
@PropertySource(value="file:config.properties", ignoreResourceNotFound =
true)})
public class ApplicationConfiguration{
private xxxxx;
private yyyyy;
Run Code Online (Sandbox Code Playgroud)
我尝试了所有可能的方法,我在谷歌上发现..没有运气.请帮忙!提前致谢.
我有一个使用 Postgresql 9.6 作为数据库的 Spring Boot 应用程序(版本 2.1.1)。我必须通过 SSL 连接到数据库sslmode=verify-ca。到目前为止我所做的是在 Application.properties 文件中设置属性
spring.datasource.url=jdbc:postgresql://`url`:`port`/`db`?
ssl=true&
sslmode=verify-ca&
sslcert=`path_to_client_cert`&
sslkey=`path_to_client_key`&
sslrootcert=`path_to_ca_cert`
Run Code Online (Sandbox Code Playgroud)
有没有办法在其他一些 spring 属性中而不是在连接 url 中指定 ssl 属性?
此外,是否可以为证书指定相对路径而不是使用绝对路径?
java postgresql ssl-certificate spring-boot application.properties
我有两个 Spring Boot 应用程序。第一个是 API 库,它作为依赖 jar 被拉入第二个(Web 应用程序)。
第一个是 API 库,其中包含在 IBM 解决方案中创建“案例”的函数。它是一个独立的类型 jar,具有一个服务类,该服务类公开 getCaseXMLForDocId(String docId) 或 createCaseForAgreementNumber(StringgreementNumber) 等方法
第一个名为 CaseInitationAPI 的库有一个 application.properties 文件,其中包含多个属性。例如:
caseinvocation.query.fetchNonProcessedCaseXml=SELECT Id, CaptureSource, AgreementNumber, CaptureSourceID FROM CaseInvocation WHERE ProcessIndicator IN (0, 2)
Run Code Online (Sandbox Code Playgroud)
服务类有一个进行查询的方法,从使用 application.properties 文件中的属性填充的成员变量中获取查询字符串:
@Value("${caseinvocation.query.fetchNonProcessedCaseXml}")
private String selectNonProcessedQueryString;
Run Code Online (Sandbox Code Playgroud)
第二个 SpringBoot 应用程序是一个具有 REST 控制器的 Web 应用程序。这些控制器公开调用 CaseInitationAPI 库(特别是 CaseInitationService 类)的端点。
我遇到的问题是,当 SpringBoot WEBAPPLICATION 启动时,上下文配置会崩溃,并出现以下错误:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'caseinvocation.query.fetchNonProcessedCaseXml' in string value "${caseinvocation.query.fetchNonProcessedCaseXml}"
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:219)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:193)
at …Run Code Online (Sandbox Code Playgroud) 我对 Spring 世界很陌生。我使用application.properties来设置不同的端口值。如何注释 application.properties 文件中的某些代码?
spring-boot ×8
java ×5
spring ×2
eclipse ×1
java-11 ×1
junit ×1
maven ×1
multi-module ×1
postgresql ×1
quarkus ×1
spring-jdbc ×1
yaml ×1