Quartz Scheduler创建没有quartz.properties的schedulerFactoryBean Beans(Quartz Scheduler create schedulerFactoryBean Beans without quartz.properties)
我在我的spring应用程序中运行了石英调度程序。
现在,我正在使用quartz.properties来包含任何属性值,并使用它来创建schedulerFactoryBean Bean,它工作正常。
这是我的QuartzConfiguration ..
@Configuration public class QuartzConfiguration { public static final String CONTEXT_KEY = "applicationContext"; //@Autowired //private DataSource dataSource; @Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean scheduler = new SchedulerFactoryBean(); scheduler.setApplicationContextSchedulerContextKey(CONTEXT_KEY); scheduler.setConfigLocation(new ClassPathResource("config/quartz.properties")); //scheduler.setDataSource(dataSource); //scheduler.setAutoStartup(true); scheduler.setWaitForJobsToCompleteOnShutdown(true); return scheduler; } }
我的quartz.properties:
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate org.quartz.jobStore.useProperties=false org.quartz.jobStore.dataSource=myDS org.quartz.dataSource.myDS.driver =oracle.jdbc.OracleDriver org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@example:1521:db org.quartz.dataSource.myDS.user = user org.quartz.dataSource.myDS.password = password org.quartz.dataSource.myDS.maxConnections = 5 org.quartz.dataSource.myDS.validationQuery = select 1 from dual org.quartz.jobStore.isClustered=false org.quartz.jobStore.tablePrefix = DPPA.QUARTZ_ org.quartz.threadPool.threadCount=1 org.quartz.scheduler.skipUpdateCheck=true org.quartz.plugin.jobHistory.class=id.co.fifgroup.dpa.batch.BatchHistoryListener
我想创建没有任何quartz.properties的schedulerFactoryBean,因为我的客户端不想更改war archieve中的任何数据库连接。
是否可以创建没有任何quartz.properties的schedulerFactoryBean?
I have running quartz scheduler with inside my spring app.
right now, i'm using quartz.properties to contain any properties value and use it to create schedulerFactoryBean Bean and it works fine.
this is my QuartzConfiguration..
@Configuration public class QuartzConfiguration { public static final String CONTEXT_KEY = "applicationContext"; //@Autowired //private DataSource dataSource; @Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean scheduler = new SchedulerFactoryBean(); scheduler.setApplicationContextSchedulerContextKey(CONTEXT_KEY); scheduler.setConfigLocation(new ClassPathResource("config/quartz.properties")); //scheduler.setDataSource(dataSource); //scheduler.setAutoStartup(true); scheduler.setWaitForJobsToCompleteOnShutdown(true); return scheduler; } }
My quartz.properties :
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate org.quartz.jobStore.useProperties=false org.quartz.jobStore.dataSource=myDS org.quartz.dataSource.myDS.driver =oracle.jdbc.OracleDriver org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@example:1521:db org.quartz.dataSource.myDS.user = user org.quartz.dataSource.myDS.password = password org.quartz.dataSource.myDS.maxConnections = 5 org.quartz.dataSource.myDS.validationQuery = select 1 from dual org.quartz.jobStore.isClustered=false org.quartz.jobStore.tablePrefix = DPPA.QUARTZ_ org.quartz.threadPool.threadCount=1 org.quartz.scheduler.skipUpdateCheck=true org.quartz.plugin.jobHistory.class=id.co.fifgroup.dpa.batch.BatchHistoryListener
i want to create schedulerFactoryBean without any quartz.properties, because my client dont want to change any database connection inside the war archieve.
is it possible to create schedulerFactoryBean without any quartz.properties ?
原文:https://stackoverflow.com/questions/43464977
最满意答案
你可以使用varargs:
public void loadFiles(String... fileNames) throws FileNotFoundException, IOException { BufferedReader[] buf_file = new BufferedReader[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { buf_file[i] = new BufferedReader(new FileReader(new File(fileNames[i]))); } }
它允许你的方法被任意数量的文件名称调用:
loadFiles("a.txt"); loadFiles("a.txt", "b.txt"); ...
当有一个简单的选择时,不需要不必要的方法重载。
You can use varargs :
public void loadFiles(String... fileNames) throws FileNotFoundException, IOException { BufferedReader[] buf_file = new BufferedReader[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { buf_file[i] = new BufferedReader(new FileReader(new File(fileNames[i]))); } }
Which allows your method to be called with any number of file names :
loadFiles("a.txt"); loadFiles("a.txt", "b.txt"); ...
No need for unnecessary method overloading when there's a simple alternative.
相关问答
更多-
Necro但是:不要使用Runtime.exec(String)重载。 根据javadoc (间接),它会在任何空格处对命令进行标记,忽略在您通过CMD(或Unix shell)直接输入此命令行时将应用的引用规则。 然后Windows执行程序从令牌重建命令行,丢失额外的空格。 而是使用String[]重载和正确的解析: p = runtime.exec(new String[]{"cmd","/c","java","-cp",classpath,classname,"hello world"}); ...
-
你可以使用varargs: public void loadFiles(String... fileNames) throws FileNotFoundException, IOException { BufferedReader[] buf_file = new BufferedReader[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { buf_file[i] = new BufferedRe ...
-
连接多个字符串?(Concatenating multiple strings?)[2022-07-13]
你想要一个空的C字符串? 这是你在找什么: char p[] = ""; ? UPDATE 在发布一些代码后,很明显你忘记了分配缓冲区temp 。 只需首先运行参数,计算所需的长度(使用strlen),然后分配temp 。 不要忘记零终结者的空间! You want an empty C string? Is this what you are looking for: char p[] = "";? UPDATE After you posted some code it is clear that yo ... -
构建将字符串映射到其“类别”的映射。 Map
category = new HashMap (); category.put("hammer", "tool"); category.put("screwdriver", "tool"); category.put("horse", "animal"); 然后你只需使用category.get(str)来获取类别。 如果它们是静态的,那么最好用Guava ImmutableMap服务 ,可能使用它 ... -
您可以使用Function.prototype.apply()方法为函数提供参数列表。 第一个参数集为函数设置“this”绑定,因此对于不在对象范围内操作的函数,可以传递null作为第一个参数。 var hash = "#some/place?id=42&&age=33&&name=Brian"; var getParams = function(hash){ var parameters = [ ["id=","&&age"],["age=","&&name"],["name=",null] ]; ...
-
检查你的_enabled实例它不是一个String它的bool和bool没有isEmpty属性。 你的if语句将是: if (_username!.isEmpty || _email!.isEmpty || _enabled!){ // Do stuff to say error }else{ // Do stuff to say success } Check your _enabledinstance its not a String its a bool an ...
-
传递给Process.Start的参数中的字符串编码错误(String encoding error in arguments passed to Process.Start)[2024-01-17]
您可能需要使用以下代码检查文件: process.StartInfo.FileName = CpdfPath()。Normalize(NormalizationForm.FormD) 看看哪种NormalizationForm最适合你: FormC 如果可能,指示使用完全规范分解对Unicode字符串进行规范化,然后使用主要组合替换序列。 FormD 指示使用完整规范分解对Unicode字符串进行规范化。 FormKC 指示使用完全兼容性分解对Unicode字符串进行规范化,然后如果可能的话,用其主要组合替 ... -
你可以试试这个: Dim Testsettings As String = "/Testsettings:""" Dim Testcontainer As String = " /Testcontainer:""" Dim Resultsfile As String = " /Resultsfile:""" Dim Quote As String = """" Dim p As New Process() p.StartInfo.FileName = Environment.GetEnvironmentV ...
-
这是同样的想法,但有一些改进。 将您的停用词list转换为一set以便更快地查找。 然后,您可以在列表解析中迭代您的短语列表。 然后,您可以迭代短语中的单词,如果它们不在停止集中,则保留它们,然后将短语重新join 。 >>> lis = ['aka', 'this is a good day', 'a pretty dog'] >>> stopwords = ['a', 'dog'] >>> stop = set(stopwords) >>> [' '.join(j for j in i.split(' ...
-
您可以使用|进行正则表达式匹配 (要么): if user_input.match? /string_a|string_b|string_c|string_d_keyword/ … end 如果您的字符串在数组中,您可以使用Regex.union将它们转换为相应的正则表达式: if user_input.match? Regex.union(strings) … end You can do a regex match using | (or): if user_input.match? /st ...