4ed5d99c5f402eb521e599dd507491c88588a40a
[dcaegen2/services.git] / components / datalake-handler / des / src / main / java / org / onap / datalake / des / DesApplication.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : Data Extraction Service
4 * ================================================================================
5 * Copyright 2020 China Mobile
6 * Copyright (C) 2021 Wipro Limited
7 *=================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 *     http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
20 */
21
22 package org.onap.datalake.des;
23
24 import javax.sql.DataSource;
25
26 import org.springframework.boot.SpringApplication;
27 import org.springframework.boot.autoconfigure.SpringBootApplication;
28 import org.springframework.boot.jdbc.DataSourceBuilder;
29 import org.springframework.context.annotation.Bean;
30
31 import springfox.documentation.swagger2.annotations.EnableSwagger2;
32
33 /**
34  * Entry point of the Data Extraction Service application.
35  * 
36  * @author Kai Lu
37  *
38  */
39
40 @SpringBootApplication(scanBasePackages = { "org.onap.datalake.*" })
41 @EnableSwagger2
42 public class DesApplication {
43
44     public static void main(String[] args) {
45         SpringApplication.run(DesApplication.class, args);
46     }
47
48     @Bean
49     public DataSource dataSource() {
50
51         String url = "jdbc:postgresql://" + System.getenv("PG_HOST").trim() + ":" + System.getenv("PG_PORT").trim() + "/datalake";
52         return DataSourceBuilder.create().url(url).username(System.getenv("PG_USER").trim())
53                 .password(System.getenv("PG_PASSWORD").trim()).build();
54     }
55
56 }