Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
踏雪无痕ouo
stu_spring
提交
245aacb4
S
stu_spring
项目概览
踏雪无痕ouo
/
stu_spring
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stu_spring
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
245aacb4
编写于
3月 22, 2023
作者:
踏雪无痕ouo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
spring读取property配置文件
上级
8616736f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
0 deletion
+102
-0
Pom_Parent/pom.xml
Pom_Parent/pom.xml
+36
-0
ReadProperty/pom.xml
ReadProperty/pom.xml
+24
-0
ReadProperty/src/main/java/Demo.java
ReadProperty/src/main/java/Demo.java
+15
-0
ReadProperty/src/main/resources/applicationContext.xml
ReadProperty/src/main/resources/applicationContext.xml
+9
-0
ReadProperty/src/main/resources/jdbc.properties
ReadProperty/src/main/resources/jdbc.properties
+4
-0
ReadProperty/src/main/resources/jdbc.xml
ReadProperty/src/main/resources/jdbc.xml
+14
-0
未找到文件。
Pom_Parent/pom.xml
0 → 100644
浏览文件 @
245aacb4
<?xml version="1.0" encoding="UTF-8"?>
<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>
com.wsstart
</groupId>
<artifactId>
Pom_Parent
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
<version>
5.1.9.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.16
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.1.2
</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
ReadProperty/pom.xml
0 → 100644
浏览文件 @
245aacb4
<?xml version="1.0" encoding="UTF-8"?>
<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>
com.wsstart
</groupId>
<artifactId>
ReadProperty
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
com.wsstart
</groupId>
<artifactId>
Pom_Parent
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
ReadProperty/src/main/java/Demo.java
0 → 100644
浏览文件 @
245aacb4
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
public
class
Demo
{
public
static
void
main
(
String
[]
args
)
{
ClassPathXmlApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
"applicationContext.xml"
);
DruidDataSource
dataSource
=
(
DruidDataSource
)
applicationContext
.
getBean
(
"dataSource"
);
System
.
out
.
println
(
dataSource
);
}
}
ReadProperty/src/main/resources/applicationContext.xml
0 → 100644
浏览文件 @
245aacb4
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"
>
<import
resource=
"classpath:jdbc.xml"
></import>
</beans>
\ No newline at end of file
ReadProperty/src/main/resources/jdbc.properties
0 → 100644
浏览文件 @
245aacb4
jdbc.driver
=
com.mysql.jdbc.Driver
jdbc.url
=
jdbc:mysql://localhost:3306/mybatis_db
jdbc.username
=
root
jdbc.password
=
root
\ No newline at end of file
ReadProperty/src/main/resources/jdbc.xml
0 → 100644
浏览文件 @
245aacb4
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"
>
<context:property-placeholder
location=
"classpath:jdbc.properties"
></context:property-placeholder>
<bean
class=
"com.alibaba.druid.pool.DruidDataSource"
id=
"dataSource"
>
<property
name=
"driverClassName"
value=
"${jdbc.driver}"
></property>
<property
name=
"url"
value=
"${jdbc.url}"
></property>
<property
name=
"username"
value=
"${jdbc.username}"
></property>
<property
name=
"password"
value=
"${jdbc.password}"
></property>
</bean>
</beans>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录