Skip to content

Commit 6b4362b

Browse files
authored
Add files via upload
1 parent 2c2aaf5 commit 6b4362b

File tree

7 files changed

+158
-0
lines changed

7 files changed

+158
-0
lines changed

pom.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.5.0</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.javatechie</groupId>
12+
<artifactId>springboot-azuresql</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>springboot-azuresql</name>
15+
<description>Demo project for Spring Boot</description>
16+
<properties>
17+
<java.version>1.8</java.version>
18+
</properties>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-data-jpa</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter-web</artifactId>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>org.projectlombok</groupId>
31+
<artifactId>lombok</artifactId>
32+
<optional>true</optional>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>com.microsoft.sqlserver</groupId>
37+
<artifactId>mssql-jdbc</artifactId>
38+
<scope>runtime</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-test</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.springframework.boot</groupId>
51+
<artifactId>spring-boot-maven-plugin</artifactId>
52+
<configuration>
53+
<excludes>
54+
<exclude>
55+
<groupId>org.projectlombok</groupId>
56+
<artifactId>lombok</artifactId>
57+
</exclude>
58+
</excludes>
59+
</configuration>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
64+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.javatechie.azure;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
import javax.persistence.Entity;
8+
import javax.persistence.GeneratedValue;
9+
import javax.persistence.Id;
10+
import javax.persistence.Table;
11+
12+
@Entity
13+
@Table
14+
@Data
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
public class Employee {
18+
@Id
19+
@GeneratedValue
20+
private int id;
21+
private String name;
22+
private String dept;
23+
private long salary;
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.javatechie.azure;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
5+
public interface EmployeeRepository extends JpaRepository<Employee,Integer> {
6+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.javatechie.azure;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.PostMapping;
8+
import org.springframework.web.bind.annotation.RequestBody;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
import java.util.List;
12+
13+
@SpringBootApplication
14+
@RestController
15+
public class SpringbootAzuresqlApplication {
16+
17+
@Autowired
18+
private EmployeeRepository repository;
19+
20+
@PostMapping("/employee")
21+
public Employee addEmployee(@RequestBody Employee employee) {
22+
return repository.save(employee);
23+
}
24+
25+
@GetMapping("/employees")
26+
public List<Employee> getEmployees() {
27+
return repository.findAll();
28+
}
29+
30+
31+
public static void main(String[] args) {
32+
SpringApplication.run(SpringbootAzuresqlApplication.class, args);
33+
}
34+
35+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/main/resources/application.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
spring:
2+
datasource:
3+
url: jdbc:sqlserver://javatechie.database.windows.net:1433;database=javatechiedb;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
4+
username: javatechie
5+
password: password@123
6+
jpa:
7+
show-sql: true
8+
hibernate:
9+
ddl-auto: update
10+
dialect : org.hibernate.dialect.SQLServer2012Dialect
11+
12+
server:
13+
port: 9191
14+
15+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.javatechie.azure;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.boot.test.context.SpringBootTest;
5+
6+
@SpringBootTest
7+
class SpringbootAzuresqlApplicationTests {
8+
9+
@Test
10+
void contextLoads() {
11+
}
12+
13+
}

0 commit comments

Comments
 (0)