- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Maven 项目中有这个配置类:
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import lombok.Data;
@Data
@Configuration
public class SmsConfig {
@Value("${sms.domainId}")
private String domainId;
@Value("${sms.gateway.url}")
private String gatewayUrl;
@Value("${sms.cmd}")
private String cmd;
@Value("${sms.login}")
private String login;
@Value("${sms.passwd}")
private String passwd;
}
我在 Spring 项目中有这个服务类:
Service("smsService")
public class AltiriaSMSRestServiceImpl implements SmsService {
private final SmsConfig smsConfig;
public AltiriaSMSRestServiceImpl(SmsConfig smsConfig) {
this.smsConfig = smsConfig;
}
@Override
public boolean sendSMS(String msg, String to) throws Exception {
...
}
...
}
这个测试:
@ContextConfiguration(classes = { SmsConfig.class })
@RunWith(SpringJUnit4ClassRunner.class)
public class AltiriaSMSRestServiceImplTest {
@Autowired
@Qualifier("smsService")
private AltiriaSMSRestServiceImpl smsService;
@Test
public void testSendSMS() throws Exception {
smsService.sendSMS("this is a test", "+34776498");
}
}
在 IntelliJ IDEA 上,配置类上的值似乎设置正确
但是当我运行测试时,Junit 测试不会替换 placeHolders
5:25:40.009 [main] DEBUG org.springframework.web.client.RestTemplate - Writing [{ "credentials":{"domainId":"${sms.domainId}","login":"${sms.login}","passwd":"${sms.passwd}"},"destination":["32470855126"], "message":{"msg":"this is a test","concat":"true", "encoding":"unicode"} }] as "application/json"
这是我的 pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
<scope>provided</scope>
<version>1.18.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
<scope>test</scope>
</dependency>
</dependencies>
最佳答案
@ContextConfiguration(classes = { SmsConfig.class, AltiriaSMSRestServiceImpl.class})
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(locations="classpath:application.properties")
public class AltiriaSMSRestServiceImplTest {
..
}
关于java - Junit 测试不会取代 placeHolders,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59008681/
我已经开始学习 tensorflow,但很难理解占位符/变量问题。 我正在尝试编写一个矩阵乘法函数。它在使用 tf.constant 时有效,但我很难理解如何使用变量 这是我的代码 import te
我正在尝试匹配两个 URL,一个带有占位符,一个带有 Angular 中的填充占位符和 TypeScript。 例如 URL 在占位符被填充之前: http://this/is/{placeholde
我正在尝试理解 std::bind。我编写了以下程序。 #include
结果:两个属性文件均已加载 其中properties_location是“a.properties,b.properties” result: Exception in thread "main"
根据this推荐的解决方案是让 Placeholder 实现 Parcelable 接口(interface)。但在我的例子中,Placeholder 已经是一个接口(interface),因此无法实
当我尝试更改 input 元素的 placeholder 属性时,它已成功完成。如果我将其更改为 MVC 中的 textboxfor 或 textareafor 元素,即使我使用 @placehold
我在我的 Pycharm 中编写了以下代码,它在 Tensorflow 中执行完全连接层 (FCL)。占位符发生无效参数错误。所以我在占位符中输入了所有的dtype、shape和name,但我仍然得到
当我尝试使用 removeAttr('placeholder') 从输入元素中删除占位符属性时:placeholder-shown 伪类不会从元素中删除,而是会更改输入值的颜色。 $(document
这很可能是一个错误,但我在这里报告它以供引用,并希望有人能够提出解决方法。 IE 11 在 textarea 元素上原生支持 placeholder 属性。那太棒了。但是,向 DOM 添加一个带有占位
尝试运行此代码时出现上述意外错误: # -*- coding: utf-8 -*- """ Created on Fri Jun 24 10:38:04 2016 @author: andrea ""
MVC 5.2.2 Razor 3.2.2 剑道 MVC UI v2014.2.903 在 Javascript 中,当我想更改 ComboBoxFor 的占位符文本时,我想我可以这样做: @mode
我想像这样向占位符添加一个图标 $("#tag_list").select2({ allowClear: true, placeholder: " inout
我们可以在play2的anorm中编写如下的sqls: def findById(id: String): Option[Link] = DB.withConnection {implicit con
在我的 iOS 应用程序中,我有一个简单的 View ,我以编程方式向其中添加了 TabBar 和 Navigation Bar。我使用 Interface Builder 添加了几个 GUI 元素。
我有这个代码 var i = 1 println(i) //result is 1 println(%02i) //is wrong 我希望它输出 01 而不是 1 最佳答案 不幸的是,你不能像这
我有一个简单的 HTML 表单,其中包含输入: 我有一个 JS 函数来检查输入的值是否为空,如果是,则用占位符的值填充它(对于非 Webkit 浏览器)。现在我想阻止保存占位符的值,所以我编写了一个
我正在使用 mathiasbynens / jquery-placeholder在 IE9 中启用占位符。我遵循了自述文件中提到的简单步骤。 但我在 $('input, textarea').plac
由于并非所有用户都保证支持 HTML 5 占位符属性,因此我尝试在 JavaScript 中为其构建解决方法: $(document).ready(function() { var searc
下面的链接将在 http://placehold.it 提供的占位符图像上打印“hello world” http://placehold.it/200&text=hello+world 是否可以在上
有没有办法设置“占位符”并稍后在逐行创建文本文件时编辑此部分,或者我是否必须最后进行行搜索并编辑此部分? 我想用常量对选定的行进行计数,如果到达文件末尾,我想将列表常量的总和写入文件头。 CONSTA
我是一名优秀的程序员,十分优秀!