Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老大叔也想要天天的爱情
DolphinScheduler
提交
a6bd568d
DolphinScheduler
项目概览
老大叔也想要天天的爱情
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a6bd568d
编写于
9月 29, 2019
作者:
Q
qiaozhanwei
提交者:
lgcareer
9月 29, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ConnectionFactoryTest and ConnectionFactory read datasource from appliction.yml (#931)
上级
0798b7d1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
78 deletion
+73
-78
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/MybatisPlusConfig.java
...apache/dolphinscheduler/dao/config/MybatisPlusConfig.java
+16
-0
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/YmlConfig.java
...ava/org/apache/dolphinscheduler/dao/config/YmlConfig.java
+17
-9
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java
...he/dolphinscheduler/dao/datasource/ConnectionFactory.java
+7
-6
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/DatabaseConfiguration.java
...olphinscheduler/dao/datasource/DatabaseConfiguration.java
+0
-63
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ConnectionFactoryTest.java
...he/dolphinscheduler/dao/mapper/ConnectionFactoryTest.java
+33
-0
未找到文件。
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/MybatisPlusConfig.java
浏览文件 @
a6bd568d
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dolphinscheduler.dao.config
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/YmlConfig.java
浏览文件 @
a6bd568d
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dolphinscheduler.dao.config
;
...
...
@@ -10,12 +26,9 @@ import java.util.Iterator;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* Created by qiaozhanwei on 2019/9/17.
*/
public
class
YmlConfig
{
p
rivate
static
Map
<
String
,
String
>
allMap
=
new
HashMap
<
String
,
String
>();
p
ublic
static
Map
<
String
,
String
>
allMap
=
new
HashMap
<
String
,
String
>();
static
{
Yaml
yaml
=
new
Yaml
();
InputStream
inputStream
=
YmlConfig
.
class
.
getResourceAsStream
(
"/application.yml"
);
...
...
@@ -26,11 +39,6 @@ public class YmlConfig {
}
}
public
static
void
main
(
String
[]
args
)
{
String
ss
=
allMap
.
get
(
"spring.datasource.url"
);
System
.
out
.
println
(
ss
);
}
public
static
void
iteratorYml
(
Map
map
,
String
key
){
Iterator
iterator
=
map
.
entrySet
().
iterator
();
while
(
iterator
.
hasNext
()){
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java
浏览文件 @
a6bd568d
...
...
@@ -17,6 +17,7 @@
package
org.apache.dolphinscheduler.dao.datasource
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.dolphinscheduler.dao.config.YmlConfig
;
import
org.apache.ibatis.mapping.Environment
;
import
org.apache.ibatis.session.Configuration
;
import
org.apache.ibatis.session.SqlSession
;
...
...
@@ -29,7 +30,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
javax.sql.DataSource
;
import
java.util.Map
;
/**
...
...
@@ -45,11 +46,11 @@ public class ConnectionFactory {
*/
public
static
DruidDataSource
getDataSource
()
{
DruidDataSource
druidDataSource
=
new
DruidDataSource
();
druidDataSource
.
setDriverClassName
(
"com.mysql.jdbc.Driver"
);
druidDataSource
.
setUrl
(
"jdbc:mysql://192.168.220.188:3306/escheduler?useUnicode=true&characterEncoding=UTF-8"
);
druidDataSource
.
setUsername
(
"root"
);
druidDataSource
.
setPassword
(
"root@123"
);
Map
<
String
,
String
>
allMap
=
YmlConfig
.
allMap
;
druidDataSource
.
setDriverClassName
(
allMap
.
get
(
"spring.datasource.driver-class-name"
)
);
druidDataSource
.
setUrl
(
allMap
.
get
(
"spring.datasource.url"
)
);
druidDataSource
.
setUsername
(
allMap
.
get
(
"spring.datasource.username"
)
);
druidDataSource
.
setPassword
(
allMap
.
get
(
"spring.datasource.password"
)
);
druidDataSource
.
setInitialSize
(
5
);
druidDataSource
.
setMinIdle
(
5
);
druidDataSource
.
setMaxActive
(
20
);
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/DatabaseConfiguration.java
已删除
100644 → 0
浏览文件 @
0798b7d1
///*
// * Licensed to the Apache Software Foundation (ASF) under one or more
// * contributor license agreements. See the NOTICE file distributed with
// * this work for additional information regarding copyright ownership.
// * The ASF licenses this file to You under the Apache License, Version 2.0
// * (the "License"); you may not use this file except in compliance with
// * the License. You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package org.apache.dolphinscheduler.dao.datasource;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.context.annotation.PropertySource;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.PlatformTransactionManager;
//
//import java.sql.SQLException;
//
///**
// * data base configuration
// */
//@Configuration
//@PropertySource({"classpath:application.yml"})
//@MapperScan(basePackages = "org.apache.dolphinscheduler.dao.mapper", sqlSessionFactoryRef = "SqlSessionFactory")
//public class DatabaseConfiguration {
//
// /**
// * register data source
// */
// @Primary
// @Bean(name = "DataSource", initMethod = "init", destroyMethod = "close")
// public DruidDataSource dataSource() {
// return ConnectionFactory.getDataSource();
// }
//
// @Primary
// @Bean(name = "SqlSessionFactory")
// public SqlSessionFactory sqlSessionFactory() throws Exception {
// SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
// sqlSessionFactoryBean.setDataSource(dataSource());
//
// return sqlSessionFactoryBean.getObject();
// }
//
// @Primary
// @Bean(name = "TransactionManager")
// public PlatformTransactionManager transactionManager() throws SQLException {
// return new DataSourceTransactionManager(dataSource());
// }
//}
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ConnectionFactoryTest.java
0 → 100644
浏览文件 @
a6bd568d
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dolphinscheduler.dao.mapper
;
import
org.apache.dolphinscheduler.dao.datasource.ConnectionFactory
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.sql.Connection
;
public
class
ConnectionFactoryTest
{
@Test
public
void
testConnection
()
throws
Exception
{
Connection
connection
=
ConnectionFactory
.
getDataSource
().
getPooledConnection
().
getConnection
();
Assert
.
assertEquals
(
connection
!=
null
,
true
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录