我正在使用spring boot并application.properties在开发过程中选择一个数据库@Configuration @Profile("dev").
spring.profiles.active=dev
spring.config.location=file:d:/application.properties
Run Code Online (Sandbox Code Playgroud)
在生产过程中,我想创建一个应该加载的应用程序上下文之外的文件,然后使用d:/application.properties激活不同的配置文件:
spring.profiles.active=production
Run Code Online (Sandbox Code Playgroud)
结果:当我启动应用程序时,配置仍然是dev,因此不会考虑生产属性文件的其他位置.我错过了什么吗?
弹簧靴1.1.0.BUILD-SNAPSHOT
注意:这个问题不是关于tomcat的.
我想创建一个spring-batch作业,但我想在没有任何数据库持久性的情况下运行它.不幸的是,spring-batch需要以metadata某种方式将ob作业周期写入数据库,从而促使我至少提供某种db与transactionmanager和entitymanager.
是否可以阻止元数据并独立于txmanagers和数据库运行?
更新:
ERROR org.springframework.batch.core.job.AbstractJob: Encountered fatal error executing job
java.lang.NullPointerException
at org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus(MapJobExecutionDao.java:158) ~[spring-batch-core-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:161) ~[spring-batch-core-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) ~[spring-tx-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) ~[spring-tx-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[spring-tx-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at com.sun.proxy.$Proxy134.update(Unknown Source) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) …Run Code Online (Sandbox Code Playgroud) <div class="value test" />
我想确定那个网络元素.它只定义了这两个类.由于className不采用空格分隔值,因此无法执行以下操作.什么是替代品?
@FindBy(className = "value test")
@CacheLookup
private WebElement test;
Run Code Online (Sandbox Code Playgroud) 为什么我不能@FunctionalInterface使用默认方法实现创建?
@FunctionalInterface
public interface MyInterface {
default boolean authorize(String value) {
return true;
}
}
Run Code Online (Sandbox Code Playgroud) 我可以将输入文本字段值传递给bean方法而不将值绑定到bean属性吗?
<h:inputText value="#{myBean.myProperty}" />
<h:commandButton value="Test" action="#{myBean.execute()} />
Run Code Online (Sandbox Code Playgroud)
我可以不进行临时保存#{myBean.myProperty}吗?
是否有更好的方法将整个html文件读取到单个字符串变量:
String content = "";
try {
BufferedReader in = new BufferedReader(new FileReader("mypage.html"));
String str;
while ((str = in.readLine()) != null) {
content +=str;
}
in.close();
} catch (IOException e) {
}
Run Code Online (Sandbox Code Playgroud) @Scheduled(fixedDelay = 5000)
public void myJob() {
Thread.sleep(12000);
}
Run Code Online (Sandbox Code Playgroud)
如果上一个例程尚未完成,如何防止此弹簧作业运行?
@RunWith(SpringJUnit4ClassRunner.class)
public void ITest {
@Autowired
private EntityRepository dao;
@BeforeClass
public static void init() {
dao.save(initialEntity); //not possible as field is not static
}
}
Run Code Online (Sandbox Code Playgroud)
如何在静态init类中注入我的服务?
如何排除具有特定类名的标记元素?
<span class="test" />
<span class="test asd" />
document.querySelectorAll('span.test'); //how to exclude all spans with "asd" as class name?
Run Code Online (Sandbox Code Playgroud) HashMap如果我想知道它们中是否包含不同的键,并且它们的值是否相互匹配,我怎样才能最好地比较两个s.
Map<objA, objB> mapA = new HashMap<objA, objB>();
mapA.put("A", "1");
mapA.put("B", "2");
Map<objA, objB> mapB = new HashMap<objA, objB>();
mapB.put("D", "4");
mapB.put("A", "1");
Run Code Online (Sandbox Code Playgroud)
将A与B进行比较时,由于键B和D不同,它应该失败.
我怎样才能最好地比较未排序的哈希图?
java ×8
spring ×4
collections ×1
comparison ×1
css ×1
file-io ×1
hashmap ×1
java-8 ×1
javascript ×1
jsf ×1
junit ×1
managed-bean ×1
selenium ×1
spring-batch ×1
spring-boot ×1
spring-test ×1