是否可以使用可选功能在TypeScript中创建接口?
interface IElement {
name: string;
options: any;
type: string;
value?: string;
validation(any): boolean; // --> should be optional.
}
Run Code Online (Sandbox Code Playgroud) 我想抑制一些方法的Sonar lint插件警告,这个问题不是我想要的Intellij SonarLint 2.3 - 忽略规则.
目前我必须用方法注释@SuppressWarnings("all"),这会抑制所有警告.
我有一个canvas装有png图像的.我jpg通过.toDataURL()这样的方法得到它的base64字符串:
$('#base64str').val(canvas.toDataURL("image/jpeg"));
Run Code Online (Sandbox Code Playgroud)
但是png图像的透明部分在新jpg图像中显示为黑色.
任何解决方案将此颜色更改为白色?提前致谢.
Exceptions.kt:
@Suppress("NOTHING_TO_INLINE")
inline fun generateStyleNotCorrectException(key: String, value: String) =
AOPException(key + " = " + value)
Run Code Online (Sandbox Code Playgroud)
在kotlin:
fun inKotlin(key: String, value: String) {
throw generateStyleNotCorrectException(key, value) }
Run Code Online (Sandbox Code Playgroud)
它在kotlin中工作,并且函数是内联的.
但是当在Java代码中使用时,它只是无法内联,并且仍然是一个正常的静态方法调用(从反编译的内容中看到).
像这样的东西:
public static final void inJava(String key, String value) throws AOPException {
throw ExceptionsKt.generateStyleNotCorrectException(key, value);
// when decompiled, it has the same contents as before , not the inlined contents.
}
Run Code Online (Sandbox Code Playgroud) 应该很简单,但我无法弄明白.
在IntelliJ中运行我的单元测试时,我找不到告诉IntelliJ-9.0它应该使用JUnit4而不是JUnit3的方法.
测试失败时,IntelliJ控制台显示:
MyTests.testConstraints(MyTests.groovy:20)at
...
com.intellij.在com.intellij的junit3.JUnit3IdeaTestRunner .doRun(JUnit3IdeaTestRunner.java:108).junit3.JUnit3IdeaTestRunner .startRunnerWithArgs(JUnit3IdeaTestRunner.java:42)...
你知道如何用JUnit4替换JUnit3吗?
我applicationContext.xml在classpath的根目录下有下一个文件:
<context:annotation-config />
<context:property-placeholder location="classpath:props/datasource.properties" />
<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource"
p:username="${jdbc.username}"
p:password="${jdbc.password}"
p:url="${jdbc.url}"
p:driverClassName="${jdbc.driverclass}"
p:validationQuery="SELECT sysdate FROM dual" />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="datasource"
p:mapperLocations="classpath:mappers/*-mapper.xml" />
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="datasource" />
<bean id="mappeScannerConfigurere" class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:sqlSessionFactory-ref="sqlSessionFactory"
p:basePackage="com.mypackage" />
Run Code Online (Sandbox Code Playgroud)
props/datasource.properties 也存在于classpath的根目录中,内容如下:
jdbc.url=myjdbcurl
jdbc.driverclass=myClass
jdbc.username=myUserName
jdbc.password=myPassword
Run Code Online (Sandbox Code Playgroud)
我有一个spring托管测试,我声明通过下一个注释使用前面提到的applicationContext.xml:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
Run Code Online (Sandbox Code Playgroud)
当我调用测试方法时,我从spring获得下一个错误:
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverclass}'
Run Code Online (Sandbox Code Playgroud)
据我所知,sping没有解析对jdbc.driverclass的引用.我做错了什么?
PS:我正在使用spring 3.2.3.RELEASE
**
**
也许问题可能在于MapperScannerConfigurer.这是一个BeanDefinitionRegistryPostProcessor和Javadoc说:
扩展到标准BeanFactoryPostProcessor SPI,允许在常规BeanFactoryPostProcessor检测开始之前注册其他bean定义
因此,MapperScannerConfigurer通过sqlSessionFactory实例化数据源对象BeanFacoryPostProcessor …
我不能在下面的访问阶段使用先前块中设置的环境变量.
pipeline{
agent any
stages{
stage("set env variable"){
steps{
script{
env.city = "Houston"
}
}
}
}
stage("access"){
steps{
sh """
set brf = ${env.city}
echo $brf
"""
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误:groovy.lang.MissingPropertyException:没有这样的属性:brf for class:groovy.lang.Binding
使用jenkins声明性管道env变量的简单方法是什么?
目前我正在使用org.apache.commons.lang.text.StrSubstitutor:
Map m = ...
substitutor = new StrSubstitutor(m);
result = substitutor.replace(input);
Run Code Online (Sandbox Code Playgroud)
鉴于我想commons-lang从项目中删除依赖项,StrSubstitutor使用标准JRE库的工作和简约实现是什么?
注意:
StrSubstitutor 像这样工作:
Map map = new HashMap();
map.put("animal", "quick brown fox");
map.put("target", "lazy dog");
StrSubstitutor sub = new StrSubstitutor(map);
String resolvedString = sub.replace("The ${animal} jumped over the ${target}.");
Run Code Online (Sandbox Code Playgroud)
屈服于resolveString ="快速的棕色狐狸跳过懒狗."
目前,我正在使用以下配置我的测试类 -
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@Transactional
Run Code Online (Sandbox Code Playgroud)
由于@TransactionConfiguration已被弃用,有什么可以更换为但─
我试过了 -
@Transactional(transactionManager = "transactionManager")
@Commit
Run Code Online (Sandbox Code Playgroud)
但我得到以下错误 -
java.lang.IllegalStateException:测试类[ca.aeso.dt.dao.impl.AssetAttributeDaoImplTest] 使用@Rollback和@TransactionConfiguration进行注释,但只允许使用一个. org.springframework.test.context.transaction.TransactionalTestExecutionListener.isDefaultRollback(TransactionalTestExecutionListener.java:383)位于org.springframework.test.context的org.springframework.test.context.transaction.TransactionalTestExecutionListener.isRollback(TransactionalTestExecutionListener.java:412) .transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:201)at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)