我想我会查看Pivotal最新发布的反应器框架,我正在编写一个简单的程序,需要一些多线程来及时完成.
我编写了以下示例项目以了解框架并使用它来了解它的使用方式:
Main.java:
package reactortest;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Main {
public static void main(String[] args) throws InterruptedException {
try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfiguration.class)) {
MyProducer producer = context.getBean(MyProducer.class);
producer.run();
}
}
}
Run Code Online (Sandbox Code Playgroud)
MyProducer.java:
package reactortest;
import java.util.concurrent.CountDownLatch;
import reactor.core.Reactor;
import reactor.event.Event;
public class MyProducer {
private final Reactor reactor;
private final Integer messagesToPrint;
private final CountDownLatch countDownLatch;
public MyProducer(final Reactor reactor, final Integer messagesToPrint, CountDownLatch countDownLatch) {
this.reactor = reactor;
this.messagesToPrint = messagesToPrint;
this.countDownLatch = countDownLatch;
}
public void …Run Code Online (Sandbox Code Playgroud) 我刚刚更新到Hibernate 4.1.5和Spring 3.1.2(从2.6ish和2.5或者其他东西......).我已设法将everthing设置为从现有数据库中读取,并且所有页面都显示正常,但是在提交数据时,没有任何内容持久保存到数据库中.我已将日志记录设置为跟踪级别以尝试跟踪此问题,并且事务将归结为从我的日志中提取的以下15行:
DEBUG - org.hibernate.internal.SessionImpl - SessionImpl - Opened session at timestamp: 13430582784
TRACE - org.hibernate.internal.SessionImpl - SessionImpl - Setting flush mode to: AUTO
TRACE - org.hibernate.internal.SessionImpl - SessionImpl - Setting cache mode to: NORMAL
TRACE - org.hibernate.event.internal.AbstractSaveEventListener - AbstractSaveEventListener - Transient instance of: ic.entities.MyEntity
TRACE - org.hibernate.event.internal.DefaultPersistEventListener - DefaultPersistEventListener - Saving transient instance
TRACE - org.hibernate.event.internal.AbstractSaveEventListener - AbstractSaveEventListener - Saving [ic.entities.MyEntity#<null>]
TRACE - org.hibernate.engine.spi.ActionQueue - ActionQueue - Adding an EntityIdentityInsertAction for [ic.entities.MyEntity] object
TRACE - org.hibernate.engine.spi.ActionQueue - ActionQueue …Run Code Online (Sandbox Code Playgroud) 我希望有一个属性设置,在某些环境中,它可以覆盖特定的属性.例如,dev的默认JDBC属性是:
问题是我们的一些开发人员希望在数据库上拥有不同的用户名/密码,甚至可能是非本地托管的数据库.我们的rabbitMQ配置也是如此,它目前使用类似的localhost,guest/guest设置.能够在每个开发人员的基础上覆盖此配置的某些元素的属性将允许我们移动大部分基础架构/安装要求,以便从本地计算机和专用服务器上构建软件.
我已经设置了一个简单的项目来围绕实现我想要的配置,这是我第一次进入spring属性配置的世界,因为到目前为止,属性加载和管理是通过一些自定义完成的码.这是我的设置:
class Main_PropertyTest {
public static void main(String[] args) {
String environment = System.getenv("APPLICATION_ENVIRONMENT"); // Environment, for example: "dev"
String subEnvironment = System.getenv("APPLICATION_SUB_ENVIRONMENT"); // Developer name, for example: "joe.bloggs"
System.setProperty("spring.profiles.active", environment);
System.setProperty("spring.profiles.sub", subEnvironment);
try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(PropertyTestConfiguration.class)) {
Main_PropertyTest main = context.getBean(Main_PropertyTest.class);
main.printProperty();
}
}
private final String property;
public Main_PropertyTest(String property) {
this.property = property;
}
public void printProperty() {
System.out.println("And the property is: '" + property …Run Code Online (Sandbox Code Playgroud) 使用delombok maven插件将我的所有文件放在'target/generated-sources/delombok'中.当我尝试运行maven编译器时,它会抱怨重复的类,所以我将addOutputDirectory设置为false,因为这个问题建议.现在的问题是delombok'ed文件被忽略,因此编译器抱怨缺少方法.
如何告诉maven编译器插件忽略默认的'src/main/java'目录,而是使用'target/generated-sources/delombok'目录进行编译?
运行mvn compile -X会在编译器运行时生成以下输出:
[DEBUG] (f) compileSourceRoots = [C:\Users\Jamey.Holden\workspace\Apollo\Website\src\main\java, C:\Users\Jamey.Holden\workspace\Apollo\Website\target\generated-sources\java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) encoding = UTF-8
[DEBUG] (f) failOnError = true
[DEBUG] (f) forceJavacCompilerUse = false
[DEBUG] (f) fork = false
[DEBUG] (f) generatedSourcesDirectory = C:\Users\Jamey.Holden\workspace\Apollo\Website\target\generated-sources\annotations
[DEBUG] (f) mojoExecution = org.apache.maven.plugins:maven-compiler-plugin:3.0:compile {execution: default-compile}
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory = C:\Users\Jamey.Holden\workspace\Apollo\Website\target\classes
[DEBUG] (f) proc = none
[DEBUG] (f) projectArtifact = ic.apollo:website:war:0.1
[DEBUG] (f) …Run Code Online (Sandbox Code Playgroud)