一:介绍
1 | liberty配置jndi数据源,这里主要是配置了MSSQL的数据源,使用了在配置文件中使用 Ref 标记来配置, |
二:配置文件介绍
2.1 创建/启动/停止server
2.2 jdni相关配置文件
2.2.1 描述
1 | 这里我创建的server是elearning,所以下面的说明都是根据elearning这个server来说的, |
2.2.2 介绍
名称 | 路径 | 描述 |
---|---|---|
server.xml | \wlp-javaee8-18.0.0.4\usr\servers \elearning\server.xml |
elearning的配置文件 |
dataSource.xml | \wlp-javaee8-18.0.0.4\usr\servers \elearning\dataSource.xml |
elearning的数据源配置文件 |
connectionManagerRef.xml | \wlp-javaee8-18.0.0.4\usr\shared \config\connectionManagerRef.xml |
数据源连接池的通用配置文件 |
containerAuthDataRef.xml | \wlp-javaee8-18.0.0.4\usr\shared \config\containerAuthDataRef.xml |
数据库认证的通用配置文件 |
jdbcDriver.xml | \wlp-javaee8-18.0.0.4\usr\shared \config\jdbcDriver.xml |
数据库驱动的通用配置文件 |
sqljdbc-4.0.0.jar | \wlp-javaee8-18.0.0.4\usr\shared \resources\sq;jdbc-4.0.0.jar |
sqlserver的驱动包 |
2.2.3 相关xml文件
server.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>javaee-8.0</feature>
</featureManager>
<!-- This template enables security. To get the full use of all the capabilities, a keystore and user registry are required. -->
<!-- For the keystore, default keys are generated and stored in a keystore. To provide the keystore password, generate an
encoded password using bin/securityUtility encode and add it below in the password attribute of the keyStore element.
Then uncomment the keyStore element. -->
<!--
<keyStore password=""/>
-->
<!--For a user registry configuration, configure your user registry. For example, configure a basic user registry using the
basicRegistry element. Specify your own user name below in the name attribute of the user element. For the password,
generate an encoded password using bin/securityUtility encode and add it in the password attribute of the user element.
Then uncomment the user element. -->
<!-- 引入dataSource数据源,如果您想要跳过找不到的包含文件,那么可以将 optional 属性设为 true: -->
<include location="dataSource.xml"/>
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
httpPort="11080"
httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
</server>dataSource.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20<server>
<featureManager>
<feature>jdbc-4.1</feature>
</featureManager>
<!-- 引用shared/config目录下的通用的配置文件 -->
<include location="${shared.config.dir}/containerAuthDataRef.xml"/> <!-- 认证用户的配置文件 -->
<include location="${shared.config.dir}/connectionManagerRef.xml"/> <!-- 数据库连接池的配置信息 -->
<include location="${shared.config.dir}/jdbcDriver.xml"/> <!-- jdbc驱动的通用配置信息 -->
<!-- sit mssql elearning -->
<dataSource
id="sit-elearning"
containerAuthDataRef="sit-mssql"
jdbcDriverRef="mssql-driver"
connectionManagerRef="sit-connectionManager"
jndiName="jdbc/elearning"
type="javax.sql.ConnectionPoolDataSource">
<properties serverName="sit" databaseName="businessplanner" portNumber="21433" />
</dataSource>
</server>containerAuthDataRef.xml
1
2
3
4
5
6
7<server>
<featureManager>
<feature>jdbc-4.1</feature>
</featureManager>
<!-- sit sqlserver -->
<authData user="sa" password="123456" id="sit-mssql"></authData>
</server>connectionManagerRef.xml
1
2
3
4
5
6<server>
<featureManager>
<feature>jdbc-4.1</feature>
</featureManager>
<connectionManager id="sit-connectionManager" minPoolSize="1" numConnectionsPerThreadLocal="10"/>
</server>jdbcDriver.xml
1
2
3
4
5
6
7
8
9
10<server>
<featureManager>
<feature>jdbc-4.1</feature>
</featureManager>
<jdbcDriver id="mssql-driver" libraryRef="mssql-lib"/>
<library id="mssql-lib">
<file name="${shared.resource.dir}\sqljdbc-4.0.0.jar"/>
</library>
</server>
三:相关参考文档
3.1 官方
- 官方-liberty目录位置和属性
- 官方-在Liberty中配置关系数据库连接
- 官方-定制 Liberty 环境
- 官方-在配置文件中使用 Ref 标记
- 官方-指定Liberty引导程序属性
- 官方-在配置文件中使用 include 元素
- 官网-SSL配置属性
3.2 其他参考文档(原创)
*************感谢您的阅读*************