小编AHH*_*AHH的帖子

找不到Postgres JDBC maven依赖项

我想在我的Java应用程序中包含Postgres JDBC驱动程序,因此我将其添加为maven依赖项.我从这个列表中选择了最后一个版本,令我惊讶的是,由Atlassian主持.现在我收到此错误:

缺少工件postgresql:postgresql:jar:9.4.1208-jdbc42-atlassian-hosted

我还尝试了一个不是由Atlassian托管的旧版本,但得到了同样的错误!是否有另一个适当的地方从罐子里拿出罐子?

这是我目前的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PostgresListener</groupId>
<artifactId>PostgresListener</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4.1208-jdbc42-atlassian-hosted</version>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

java postgresql jdbc

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

在注入构造函数之前注入成员变量

在类的注入构造函数中,我必须使用适当的参数调用超级构造函数。super 应该通过多态调用子类的方法(我有来自同一个父类的多个子类实现相同的方法)。问题是子类中的方法依赖于已经注入的成员变量。在我的例子中,子类依赖于不同类型的多个变量。此外,父类是某些库中的本地类,我无法更改。请参阅以下示例性的、非常简化的代码:

public class A {

    @Inject
    public A(SomeType t)
    {
        workon(t1);
    }
}


public class B extends A{

    @Inject
    private MemberType mt;

    @Inject
    public B(SomeType t)
    {
        super(t)
    }

    public void workOn(SomeType t)
    {
        // mt is not set yet since this method
        // is called from the super constructor!
        mt.setT(t);
    }
}
Run Code Online (Sandbox Code Playgroud)

除了手动初始化之外,有没有办法在调用继承的方法之前注入成员变量?

java dependency-injection

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

标签 统计

java ×2

dependency-injection ×1

jdbc ×1

postgresql ×1