小编mem*_*und的帖子

如何在Spring-Boot生产期间覆盖application.properties?

我正在使用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的.

java spring spring-boot

41
推荐指数
7
解决办法
9万
查看次数

Spring-Batch没有将元数据保存到数据库?

我想创建一个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)

java spring spring-batch

39
推荐指数
7
解决办法
5万
查看次数

通过多个类名来查找div元素?

<div class="value test" /> 我想确定那个网络元素.它只定义了这两个类.由于className不采用空格分隔值,因此无法执行以下操作.什么是替代品?

@FindBy(className = "value test")
@CacheLookup
private WebElement test;
Run Code Online (Sandbox Code Playgroud)

css java selenium selenium-webdriver

38
推荐指数
3
解决办法
6万
查看次数

@FunctionalInterfaces可以有默认方法吗?

为什么我不能@FunctionalInterface使用默认方法实现创建?

@FunctionalInterface
public interface MyInterface {
    default boolean authorize(String value) {
        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

java java-8

38
推荐指数
3
解决办法
1万
查看次数

将输入文本值传递给bean方法,而不将输入值绑定到bean属性

我可以将输入文本字段值传递给bean方法而不将值绑定到bean属性吗?

<h:inputText value="#{myBean.myProperty}" />
<h:commandButton value="Test" action="#{myBean.execute()} />
Run Code Online (Sandbox Code Playgroud)

我可以不进行临时保存#{myBean.myProperty}吗?

jsf parameter-passing managed-bean

37
推荐指数
2
解决办法
9万
查看次数

将整个html文件读取到String?

是否有更好的方法将整个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)

java file-io

34
推荐指数
4
解决办法
10万
查看次数

如何防止Spring中重叠的时间表?

@Scheduled(fixedDelay = 5000)
public void myJob() {
     Thread.sleep(12000);
}
Run Code Online (Sandbox Code Playgroud)

如果上一个例程尚未完成,如何防止此弹簧作业运行?

java spring spring-scheduled

34
推荐指数
2
解决办法
2万
查看次数

如何在静态@BeforeClass中自动装配字段?

@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类中注入我的服务?

java junit spring spring-test

33
推荐指数
4
解决办法
1万
查看次数

如何在querySelectorAll()中排除特定的类名?

如何排除具有特定类名的标记元素?

<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)

javascript

32
推荐指数
3
解决办法
2万
查看次数

比较相同值和相同键集的两个哈希映射?

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 collections comparison hashmap

31
推荐指数
3
解决办法
12万
查看次数