-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
334 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import org.apache.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.annotation.Resource; | ||
|
||
import repository.IUserRepository; | ||
import repository.impl.UserRepository; | ||
|
||
/** | ||
* Created by ZuoYun on 5/10/15. Time: 8:34 PM Information: | ||
*/ | ||
@RestController | ||
@EnableAutoConfiguration | ||
public class App { | ||
|
||
final static Logger logger = Logger.getLogger(App.class); | ||
|
||
@Resource | ||
JdbcTemplate template; | ||
|
||
@Autowired | ||
// IUserRepository userRepository; | ||
|
||
@RequestMapping(value = "/") | ||
@ResponseBody | ||
public Object index() { | ||
template.queryForList("show tables;"); | ||
return "hello world"; | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(App.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package domain; | ||
|
||
|
||
import org.apache.log4j.Logger; | ||
import org.springframework.data.annotation.Id; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
|
||
/** | ||
* Created by ZuoYun on 5/10/15. Time: 9:43 PM Information: | ||
*/ | ||
@Entity | ||
public class User implements Serializable { | ||
|
||
final static Logger logger = Logger.getLogger(User.class); | ||
|
||
@Id | ||
@GeneratedValue | ||
public Integer id; | ||
|
||
|
||
@Column(nullable = true) | ||
public String user; | ||
@Column(nullable = true) | ||
public String password; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(String user) { | ||
this.user = user; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package repository; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import domain.User; | ||
|
||
/** | ||
* Created by ZuoYun on 5/10/15. Time: 9:46 PM Information: | ||
*/ | ||
|
||
public interface IUserRepository extends CrudRepository<User,Integer>{ | ||
|
||
final static Logger logger = Logger.getLogger(IUserRepository.class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package repository.impl; | ||
|
||
|
||
import org.apache.log4j.Logger; | ||
import org.springframework.stereotype.Component; | ||
|
||
import domain.User; | ||
import repository.IUserRepository; | ||
|
||
/** | ||
* Created by ZuoYun on 5/10/15. Time: 9:49 PM Information: | ||
*/ | ||
@Component | ||
public class UserRepository implements IUserRepository { | ||
final static Logger logger = Logger.getLogger(UserRepository.class); | ||
|
||
|
||
@Override | ||
public User save(User entity) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <S extends User> Iterable<S> save(Iterable<S> entities) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public User findOne(Integer integer) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean exists(Integer integer) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Iterable<User> findAll() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Iterable<User> findAll(Iterable<Integer> integers) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public long count() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void delete(Integer integer) { | ||
|
||
} | ||
|
||
@Override | ||
public void delete(User entity) { | ||
|
||
} | ||
|
||
@Override | ||
public void delete(Iterable<? extends User> entities) { | ||
|
||
} | ||
|
||
@Override | ||
public void deleteAll() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
spring.datasource.url=jdbc:mysql://localhost/test | ||
spring.datasource.username=root | ||
spring.datasource.password= | ||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver | ||
|
||
|
||
spring.jpa.hibernate.ddl-auto=create-drop |