如何将yaml数组传递给--extra-varsAnsible playbook.Ansible文档没有声明它的语法,也没有在任何互联网资源上找到它.
我的意思是如果我有一本剧本:
---
- hosts: {{hostName}}
- remote_user: admin
...
Run Code Online (Sandbox Code Playgroud)
然后我应该把我的剧本称为
ansible-playbook DeployWar.yml --extra-vars="hostName=tomcat-webApp"
但我想运行这个剧本在两台服务器上说tomcat-webApp和tomcat-all,我想从出方控制它即使用--extra-vars.我试图做的是:
ansible-playbook DeployWar.yml --extra-vars="hostName=[tomcat-webApp, tomcat-all]"
ansible-playbook DeployWar.yml --extra-vars="hostName={tomcat-webApp, tomcat-all}"
ansible-playbook DeployWar.yml --extra-vars="[{hostName: tomcat-webApp}, {hostName: tomcat-all}]"
Run Code Online (Sandbox Code Playgroud)
但在所有情况下,playbook都无法在我的调用中声明语法错误.任何帮助赞赏.
Java Thread本身实现了Java Runnable!并且根据Internet上的大多数专家,实现Runnable比扩展Thread更受欢迎!即使我们不能在Thread类的线程意义上使用Runnable!
那么为什么我们更喜欢实现Runnable过度扩展,Thread因为在这两种情况下,通过调用一个Thread实现的方法(即start()或者run())来说明实际的线程,尽管在Thread我们没有真正"扩展" Thread仅通过覆盖run()方法的功能的情况下?
如果我听起来很混乱,我道歉......
我必须使用Spring在我的一个Dao类上执行单元测试.这是我的单元测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:app-config.xml"})
@ActiveProfiles("local")
public class HouseDaoTest {
@Autowired
HouseDataDao houseDataDao;
@Test
public void saveTest(){
HouseData data = new HouseData();
Address add = new Address();
// Truncating for sake of simplicity
houseDataDao.save(data);
}
}
Run Code Online (Sandbox Code Playgroud)
和我的bean配置文件:
APP-config.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="BeanConfiguration-localhost.xml"/>
<import resource="BeanConfiguration-production.xml"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
BeanConfiguration-localhost.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans profile="local"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:annotation-config />
<tx:annotation-driven />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/dbtest" /> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Benchmark.js执行示例性能基准测试.这是我写的:
var Benchmark = require('benchmark');
var arr = []
benchmark = new Benchmark('testPerf',function(){
arr.push(1000);
},
{
delay: 0,
initCount: 1,
minSamples: 1000,
onComplete : function(){ console.log(this);},
onCycle: function(){}
});
benchmark.run();
Run Code Online (Sandbox Code Playgroud)
就像我们在JUnitBenchmarks中一样:
@BenchmarkOptions(clock = Clock.NANO_TIME, callgc = true, benchmarkRounds = 10, warmupRounds = 1)
Run Code Online (Sandbox Code Playgroud)
在这里,我还要声明benchmarkRounds并warmupRounds计入benchmarkjs.我认为warmupRounds地图initCount?以及如何设置确切的周期数/基准迭代次数?
或者,如果我们有一些其他好的JavaScript库可以处理它也会工作.
JTextField.setEnabled()和之间有什么区别JTextField.setEditable()?在我的代码中,我有一个继承自的类的实例JTextField.但是当我设置它的属性时,setEnabled(false)我仍然可以在我的程序中编辑和处理它的内容.但是,当我设置其属性时,setEditable(false)我无法再编辑其文本.如果是这样的话.那么setEnabled()物业的目的是什么?
继承类的我的代码是:
private static class CCField extends JTextField{
private static final long serialVersionUID = 1L;
public CCField() {
this( DEFAULT_COLUMN_COUNT );
}
public CCField(final int cols) {
super( cols );
}
Run Code Online (Sandbox Code Playgroud)
添加INFO
当我调用setEnabled()此类的属性时,它不会对文本字段显示任何影响,它仍然保持启用状态.Jcomponent我的代码中有一个容器,它将此CCField作为子组件.因此,当我尝试使用setEnabled(false)它仍然可以编辑时禁用它.而当我尝试使用setEditable(false)它时禁用它然后它被禁用.这是我在容器中访问此textField的方式:
JComponent jComp = DDEUtil.getComponent(icTableLayout,icDS);
((JTextField)jComp.getComponent(1)).setEditable(false);
Run Code Online (Sandbox Code Playgroud)
正在发生的事情DDEUtil.getComponent太复杂了,因为它涉及许多课程而且不可能在这里发布.
我想我没有覆盖这个组件的任何方法,所以为什么它显示这种行为.
在我的android项目中,我使用的是外部jar库,它使用运行时库libiconv.so.我的库包含在项目的lib目录中.该库包含在以下目录hirarcy中的所有三种体系结构中.
libs>
armeabi>libiconv.so
armeabi-v7a>libiconv.so
x86>libiconv.so
Run Code Online (Sandbox Code Playgroud)
但我得到了log cat记录的异常:
05-23 12:18:58.857 3081-3081/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load libiconv.so from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.tariq.buynow-1.apk,libraryPath=/data/app-lib/com.tariq.buynow-1]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.tariq.buynow.CameraActivity.<clinit>(CameraActivity.java:30)
Run Code Online (Sandbox Code Playgroud)
在CameraActivity.java:30的位置是:
static { System.loadLibrary("libiconv.so"); }
Run Code Online (Sandbox Code Playgroud)
我也试过了
static { System.loadLibrary("iconv"); }
Run Code Online (Sandbox Code Playgroud)
是否与gradle配置有关,因为我是Android Studio新手,或者错误来源是其他什么?
我在log4j xml文件中有以下布局模式:
"%d{ISO8601} %c %p [%t] [%x] 9.5.4.RC12 %m%n"
我想要的是,当我得到包含消息的日志时process [proc#] completed,应该跳过它.我的意思是应该打印除包含此消息的日志之外的所有日志.[proc#]将包含最大长度的进程号4.我可以在我的xml配置文件中使用此函数设置过滤器.如果是这样,那怎么样?
在我的剧本中,我有一个条件包含语句来包含一个任务:
tasks:
# Install Java if not present
- name: Execute Java
shell: java -version
register: result
ignore_errors: True
- include: tasks/java.yml
when: result | failed
...
Run Code Online (Sandbox Code Playgroud)
当我执行playbook时,它会发出错误:
user1@localhost:~ ansible-playbook tomcat.yml
ERROR: tasks is not a legal parameter in an Ansible task or handler
Run Code Online (Sandbox Code Playgroud)
但是,当我用其他东西替换这个include语句时shell,playbook按预期运行....
Ansible docs告诉任务可以有条件地包含在内,为什么我在这里收到错误?
我正在使用NullpointerException我的保存方法CityDaoImpl.似乎sessionFactory没有自动装配,因为在调试时发现sessionFactory从未被注入CityDaoImpl.我看了很多答案,但没有一个能解决我的问题.这是我的HibernateConfig.xml档案:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan
base-package="com.testing" />
<context:annotation-config></context:annotation-config>
<tx:annotation-driven/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/sybrium" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="annotatedClasses">
<list>
<value>com.testing.bean.City</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="debug">true</prop>
</props>
</property>
</bean>
<bean id="cityDao" class="com.testing.dao.CityDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property> …Run Code Online (Sandbox Code Playgroud) 我有一个table标题和表格数据.基本上看起来像这样:
<table>
<tr>
<th>Start Time</th><th>End Time</th>
</tr>
<tr>
<td>12:00 am</td><td>01:00 am</td>
</tr>
<tr>
<td>01:00 am</td><td>02:00 am</td>
</tr>
<tr>
<td>12:00 pm</td><td>01:00 am</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
现在我想只选择数据行.不应选择标题行.我不想在我td或tr元素中添加一个类
我必须在JQuery中执行此操作,因此JQuery特定的解决方案也是可以接受的.
任何线索.
我写了一个程序,它必须从文件中获取输入并从中提取文本,同时将其内容保存到数组中.我的文本文件内容是:
There is some!text.written%in
the FILE[That]=Have+to`be==separated????
Run Code Online (Sandbox Code Playgroud)
我试图编码的是:
public static void main(String[] args) throws FileNotFoundException, IOException {
BufferedReader file = new BufferedReader(new FileReader("mfile.txt"));
List<String> list = new ArrayList();
String str;
StringBuilder filedata = new StringBuilder();
Scanner toknizer = new Scanner(filedata.toString());
while((str=file.readLine())!=null){
filedata.append(str);
}
toknizer.useDelimiter("[^a-z]");
while(toknizer.hasNext()){
list.add(toknizer.next());
}
System.out.println(list);
}
Run Code Online (Sandbox Code Playgroud)
此时我只想提取用小字母书写的文本.但该程序打印出一个空列表.调试显示toknizer.hasNext()正在返回false while(toknizer.hasNext()).怎么了?我使用错误的正则表达式吗?我[^a-z]从这里得到了使用的想法.
java ×4
spring ×2
android ×1
benchmark.js ×1
hibernate ×1
javascript ×1
jquery ×1
jtextfield ×1
log4j ×1
runnable ×1
spring-test ×1
swing ×1
unit-testing ×1
yaml ×1