我需要为java应用程序处理一组相对复杂的配置参数.要求大致如下:
现在,我知道Spring以某种方式实现了所有这些.然而,它有一些缺点,但没有致命的:
所以,我问,你能想到任何能满足我要求的替代方案吗?
我有点像YamlBeans,但缺少一些功能.
我只更改了一个源文件并重新启动了构建:
$ gradle jar
Incremental java compilation is an incubating feature.
:compileJava
Full recompilation is required because 'XXX.java' was changed.
Analysis took 0.241 secs.
Run Code Online (Sandbox Code Playgroud)
我的gradle配置有:
compileJava {
options.fork = true
options.incremental = true
}
Run Code Online (Sandbox Code Playgroud)
我希望Gradle只重新编译XXX.java,它不是应该做的吗?
你能发现这个bug吗?这将抛出一个java.lang.OutOfMemoryError.
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TestTheads {
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(1);
while(true) {
executorService.submit(new Runnable() {
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
});
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误是我调用executorService.submit()而不是executorService.execute(),因为submit()返回一个Future我忽略的对象.有了execute(),这个程序实际上将永远运行.
然而,人们并不总是拥有一种execute()方法,例如使用时ScheduledExecutorService:
public static void main(String[] args) {
// this will FAIL because I ignore the ScheduledFuture object
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2); …Run Code Online (Sandbox Code Playgroud) 我想为EJB添加依赖项.我怎么用Spring做到这一点?从属对象是一般服务对象.根据下面的代码,我想连接myDependency而不必使用'new'.EJB在weblogic中运行.
@Stateless(mappedName = "MyBean")
public class MyBean implements MyBeanRemote, MyBeanLocal {
@EJB(name = "MyOtherBean")
private MyOtherBean myOtherBean;
private MyDependency myDependency;
...
}
Run Code Online (Sandbox Code Playgroud)