Merge pull request #6 from eugenp/master

merge sync up
This commit is contained in:
vatsalgosar
2019-10-20 20:00:20 +05:30
committed by GitHub
parent db85c8f275
commit ade303a6de
20475 changed files with 1641579 additions and 0 deletions
@@ -0,0 +1,19 @@
package com.baeldung.springboot.azure;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class AzureApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AzureApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(AzureApplication.class, args);
}
}
@@ -0,0 +1,34 @@
package com.baeldung.springboot.azure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static com.baeldung.springboot.azure.User.userNamed;
/**
* @author aiet
*/
@RestController
public class TestController {
@GetMapping("/hello")
public String hello() {
return "hello azure!";
}
@Autowired private UserRepository userRepository;
@PostMapping("/user")
public String register(@RequestParam String name) {
userRepository.save(userNamed(name));
return "registered";
}
@GetMapping("/user")
public Iterable<User> userlist() {
return userRepository.findAll();
}
}
@@ -0,0 +1,43 @@
package com.baeldung.springboot.azure;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* @author aiet
*/
@Entity
public class User {
public User() {
}
public static User userNamed(String name) {
User u = new User();
u.setName(name);
return u;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,9 @@
package com.baeldung.springboot.azure;
import org.springframework.data.repository.CrudRepository;
/**
* @author aiet
*/
public interface UserRepository extends CrudRepository<User, Long> {
}
@@ -0,0 +1,16 @@
server.port=8080
server.address=0.0.0.0
spring.jpa.hibernate.ddl-auto=create
logging.file=azure.log
logging.level.root=info
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
#spring.datasource.url=jdbc:mysql://localhost:3306/localdb
#spring.datasource.username=your-db-username
#spring.datasource.password=your-db-password
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
@@ -0,0 +1,16 @@
package com.baeldung.springboot.azure;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AzureApplicationIntegrationTest {
@Test
public void contextLoads() {
}
}