HERES下载PostgreSQL JDBC驱动程序,然后将其安装在 /conf /lib文件夹中,然后更新 /conf/james-database.properties文件中的数据库地址和凭据。我遵循了指示,它起作用。
否则,由于Linagora图像似乎太老了,所以我决定要切换到原始的Apache/James:JPA*图像之一。 (根据Docker Hub,我觉得:JPA是正确的选择,但如果您觉得我误会了,请告诉我)因此,我遵循相同的说明(Mount JDBC驱动程序和更新James-Database.properties),我希望能平稳地过渡到JPA映像。
i我发现最近的JPA映像需要一个应该保存为“键盘”文件并安装在 / config / folder中的密钥对。按键必须使用“ JAMES72LABALLE”代码制作。此步骤成功了。无论我遇到一个错误,这使我变得creasy。詹姆斯(不是容器)说它无法到达我的PostgreSQL容器。它说:
linagora/james-jpa-spring
这是完整的错误消息:
There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class "org.postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb". You may have specified an invalid URL.
这是我的james-database.properties文件:
1) [Guice/ErrorInjectingConstructor]: <openjpa-3.2.0-r6f721f6 nonfatal general error> PersistenceException: There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class "org.postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb". You may have specified an invalid URL.
at DataSourceFactory.newConnectException(DataSourceFactory.java:271)
at DataSourceFactory.newDataSource(DataSourceFactory.java:121)
at JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:925)
at JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:805)
at java.base/NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/Method.invoke(Unknown Source)
at ConfigurationImpl.instantiateAll(ConfigurationImpl.java:331)
at OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1963)
at AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:665)
at AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:207)
at DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:166)
at EntityManagerFactoryImpl.doCreateEM(EntityManagerFactoryImpl.java:282)
at EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:201)
database.driverClassName=org.postgresql.Driver
database.url=jdbc:postgresql://post/jamesdb
database.username=admin
database.password=password
vendorAdapter.database=POSTGRESQL
database.url=jdbc:postgresql://post:5432/jamesdb
database.url=jdbc:postgresql://post/jamesdb;create=true
没有成功!
我已经建立了一个Docker网络,并且两个容器都在该“ Docker Network”上运行我确定我的詹姆斯容器可以访问我的邮政容器(当我尝试使用其内部德比数据库运行它时,并且不要强迫它连接到外部数据库。)因为我有詹姆斯容器的Docker-Exec Bash,并在Postgres容器(PING POST)中ping ping,并成功地做出了响应。我什至在James容器中安装了PSQL数据库管理器,并可以成功连接到Postgres容器上的数据库并操纵数据库上的数据。
我根本不明白为什么詹姆斯说它在应该访问时看不到我的PostgreSQL数据库。
除非另有说明,否则以下说明是在主机上执行的,而不是在容器上执行。eDit
database.url=jdbc:postgresql://post:5432/jamesdb;create=true
/etc/hosts申请/etc/hosts
mail.james.local
项目树
项目目录:
127.0.0.1
127.0.0.1 localhost mail.james.local
james_jpa_image
james-database.propertiesmkdir -p my_root/conf
mkdir -p my_root/libs
创建文件
my_root
├── conf
│ ├── james-database.properties (1)
│ └── keystore (2)
└── libs
├── checker-qual-3.42.0.jar (3)
└── postgresql-42.7.3.jar (4)
在james_jpa_image/my_root/conf
run命令:database.driverClassName=org.postgresql.Driver
database.url=jdbc:postgresql://my-postgres-james:5432/jamesdb
database.username=james
database.password=james123
vendorAdapter.database=POSTGRESQL
openjpa.streaming=false
SET密码:
keystore
SETCN,OU,O =
keytool -genkeypair \
-alias james \
-keyalg RSA \
-keysize 2048 \
-storetype PKCS12 \
-keystore keystore \
-validity 3650
下载JDBC JAR文件james72laBalle
和james
进入
postgresql-42.7.3.jar
Postgresql-42.7.3.jar(
Https://repo1.maven.org/maven2/org/postgresql/postgresql/postgresql/42.7.3/postgresql-42.7.3.jar,)Checker-Qual-3.42.0.jar(Https://repo1.maven.org/maven2/org/checkerframework/checker-checker-qual/checker-qual/3.42.0/checker-qhecker-qual-qual-3.42.42.0.jar,)
checker-qual-3.42.0.jar
my_root/libs
项目目录:
docker network create james-net
run命令:docker run \
--name my-postgres-james \
--network james-net \
-e POSTGRES_USER=james \
-e POSTGRES_PASSWORD=james123 \
-e POSTGRES_DB=jamesdb \
-p 5432:5432 \
-d \
postgres
james_jpa_image
docker run \
--rm \
--network james-net \
-it \
-v `pwd`/my_root/libs/postgresql-42.7.3.jar:/root/libs/postgresql-42.7.3.jar \
-v `pwd`/my_root/libs/checker-qual-3.42.0.jar:/root/libs/checker-qual-3.42.0.jar \
-v `pwd`/my_root/conf/james-database.properties:/root/conf/james-database.properties \
-v `pwd`/my_root/conf/keystore:/root/conf/keystore \
-p 143:143 \
-p 25:25 \
-p 4000:4000 \
-p 465:465 \
-p 587:587 \
-p 80:80 \
-p 8000:8000 \
-p 993:993 \
apache/james:jpa-3.8.1
james.local
:
curl -XPUT http://mail.james.local:8000/domains/james.local
[email protected]
:
Passw0rd!
[email protected]
[email protected]
中进行检查
docker JamesUptough
thunder thunder thunderbird
一切都很好
在詹姆斯服务器终端,
Passw0rd!
curl -XPUT http://mail.james.local:8000/users/[email protected] \
-d '{"password":"Passw0rd!"}' \
-H "Content-Type: application/json"
curl -XPUT http://mail.james.local:8000/users/[email protected] \
-d '{"password":"Passw0rd!"}' \
-H "Content-Type: application/json"
curl -XPUT http://mail.james.local:8000/users/[email protected] \
-d '{"password":"Passw0rd!"}' \
-H "Content-Type: application/json"
,停止詹姆斯容器。
删除后
Crtl
创建DockerPostgresql
C
项目目录:docker stop my-postgres-james
docker container rm -f -v my-postgres-james
docker run \
--name my-postgres-james \
--network james-net \
-e POSTGRES_USER=james \
-e POSTGRES_PASSWORD=james123 \
-e POSTGRES_DB=jamesdb \
-p 5432:5432 \
-d \
postgres
创建詹姆斯域和用户
上面已经提到了它,所以我不会在这里重复。
步:创建域
步:创建用户
使用Docker-Compose您可以创建自己的
james_jpa_image