小编pho*_*Sid的帖子

基于布尔变量自动装配 Spring Bean

我想以这样的方式配置 spring bean,即根据布尔变量的值,两个可用连接 bean 之一在代码中自动连接。

下面是布尔变量的初始化:

//This is overridden as false from the properties file on the server.
@Value(value = "${my.property.connectionOne:true}") 
private boolean connectionOne;
Run Code Online (Sandbox Code Playgroud)

我用这样的方式定义了 Bean:

@Bean(name = "specificConnection")
public Destination getSpecificConnection() throws Exception {
    if (connectionOne) { //boolean variable
        return new ConnectionOne("DB");
    }
    else {
        return new ConnectionTwo("XML");
    }
}
Run Code Online (Sandbox Code Playgroud)

哪里ConnectionOneConnectionTwo都实施Destination

我在所需的类中使用该 bean:

@Autowired
@Qualifier(value = "specificConnection")
private Destination specificConnection;
Run Code Online (Sandbox Code Playgroud)

然而,它似乎不起作用。ConnectionOne仅当我将布尔变量的值更改为 false 时,它​​才会继续返回。

我正在使用 Spring 版本 4.2.0 和 Wildfly Server。

如果需要进一步说明,请告诉我。

java spring

5
推荐指数
1
解决办法
3283
查看次数

如何使用JProfiler连接到jboss服务器?

我是第一次使用jprofiler,首先我下载了​​JProfiler,然后安装了JProfiler。请帮助我如何用jboss服务器配置jprofiler。我们不使用jboss服务器的默认部署,我们有特定的部署,例如C:\ jboss-4.2.2.GA \ server \ test \,我们的应用程序部署在测试文件夹中,如何使用jprofiler配置测试部署文件夹?

jboss jprofiler

2
推荐指数
1
解决办法
4681
查看次数

使用 liquibase 将 postgres 表复制到另一个架构

我想将一组表从一个模式复制到同一数据库上的另一个模式。我在 Ubuntu 上使用 postgres v9,并使用 Liquibase 对数据库进行任何更改。

我可以使用类似于下面的代码创建新表,但我需要将新表创建为select * from another table

<changeSet author="jDoe" id="1">
    <createTable tableName="abcproxy">
        <column name="errtime" type="datetime">
            <constraints primaryKey="true" nullable="false"/>
        </column>
        <column name="errmsg" type="varchar(255)">
            <constraints nullable="false"/>
        </column>
        <column name="version" type="integer">
            <constraints nullable="false"/>
        </column>
    </createTable>
Run Code Online (Sandbox Code Playgroud)

我知道我们可以通过此处提到的 sql 来完成此操作,但我想通过 Liquibase XML 配置来完成此操作。另外,如果我们可以使用 liquibase 配置复制授权/权限,那就太好了。

我可以尝试按照此处提到的方式移动表格,但到目前为止,我的要求是复制而不是移动表格。

请让我知道实现相同目标的任何建议。谢谢。

database postgresql liquibase

2
推荐指数
1
解决办法
3629
查看次数

标签 统计

database ×1

java ×1

jboss ×1

jprofiler ×1

liquibase ×1

postgresql ×1

spring ×1