diff --git a/src/com/markz/testApp/config/DataConfig.java b/src/com/markz/testApp/config/DataConfig.java index 838b7af..5e19486 100644 --- a/src/com/markz/testApp/config/DataConfig.java +++ b/src/com/markz/testApp/config/DataConfig.java @@ -2,6 +2,7 @@ import javax.sql.DataSource; +import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.Bean; @@ -10,14 +11,14 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource; @Configuration -@MapperScan("com.markz.testApp.persistence") +@MapperScan("com.markz.testApp.mappers") public class DataConfig { @Bean public DataSource dataSource() { SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass(com.mysql.jdbc.Driver.class); - String url = "jdbc:mysql://enliteinstance.c9a1yjg7i5cn.us-east-1.rds.amazonaws.com:3306:test"; + String url = "jdbc:mysql://enliteinstance.c9a1yjg7i5cn.us-east-1.rds.amazonaws.com:3306/test"; String username = "master"; String password = "enliteUs"; dataSource.setUrl(url); @@ -32,12 +33,12 @@ public DataSourceTransactionManager transactionManager() { } @Bean - public SqlSessionFactoryBean sqlSessionFactory() { + public SqlSessionFactory sqlSessionFactory() throws Exception { SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource()); sessionFactory.setTypeAliasesPackage("com.markz.testApp.objects"); - return sessionFactory; + return sessionFactory.getObject(); } } diff --git a/src/com/markz/testApp/controller/MyTestController.java b/src/com/markz/testApp/controller/MyTestController.java index decde8c..e0a2a0a 100644 --- a/src/com/markz/testApp/controller/MyTestController.java +++ b/src/com/markz/testApp/controller/MyTestController.java @@ -1,22 +1,29 @@ package com.markz.testApp.controller; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.markz.testApp.mappers.UserDetailsMapper; import com.markz.testApp.objects.UserDetail; @RestController public class MyTestController { - @RequestMapping(value="/users/{user}") - public UserDetail message(@PathVariable String user){ - UserDetail userDetail = new UserDetail(); - userDetail.setAge(21); - userDetail.setName(user); - userDetail.setUserId(user+"@markz.com"); - userDetail.setZip(53717); - - return userDetail; + @Autowired + UserDetailsMapper userDetailsMapper; + + @RequestMapping(value = "/users/{id}") + public UserDetail getUserById(@PathVariable int id) { + return userDetailsMapper.getUserDetail(id); } + + @RequestMapping(value = "/users") + public List userList() { + return userDetailsMapper.getAllUsers(); + } + } diff --git a/src/com/markz/testApp/dao/UserDetailDao.java b/src/com/markz/testApp/dao/UserDetailDao.java deleted file mode 100644 index cbd5f54..0000000 --- a/src/com/markz/testApp/dao/UserDetailDao.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.markz.testApp.dao; - -import java.util.List; - -import org.mybatis.spring.support.SqlSessionDaoSupport; - -import com.markz.testApp.objects.UserDetail; - -public class UserDetailDao extends SqlSessionDaoSupport { - - public List getAllUsers() { - return getSqlSession().selectList("getAllUsers"); - } - - public UserDetail getUserDetails(int id) { - return getSqlSession().selectOne("getgetUserDetail"); - } -} diff --git a/src/com/markz/testApp/mappers/UserDetailsMapper.java b/src/com/markz/testApp/mappers/UserDetailsMapper.java index 040025e..4224191 100644 --- a/src/com/markz/testApp/mappers/UserDetailsMapper.java +++ b/src/com/markz/testApp/mappers/UserDetailsMapper.java @@ -11,6 +11,8 @@ public interface UserDetailsMapper { // @Select("SELECT * FROM user_detail where user_id={#userId}") public UserDetail getUserDetail(int id); + public UserDetail getUserDetailByLoginId(String loginId); + // public int insertUserDetail(UserDetail userDetail); // public void updateUserDetail(UserDetail userDetail); diff --git a/src/com/markz/testApp/mappers/UserDetailsMapper.xml b/src/com/markz/testApp/mappers/UserDetailsMapper.xml new file mode 100644 index 0000000..045655b --- /dev/null +++ b/src/com/markz/testApp/mappers/UserDetailsMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/markz/testApp/persistence/UserDetailsMapper.xml b/src/com/markz/testApp/persistence/UserDetailsMapper.xml deleted file mode 100644 index bf25639..0000000 --- a/src/com/markz/testApp/persistence/UserDetailsMapper.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/target/classes/com/markz/testApp/Objects/UserDetail.class b/target/classes/com/markz/testApp/Objects/UserDetail.class index 1e3f793..c32105b 100644 Binary files a/target/classes/com/markz/testApp/Objects/UserDetail.class and b/target/classes/com/markz/testApp/Objects/UserDetail.class differ diff --git a/target/classes/com/markz/testApp/config/DataConfig.class b/target/classes/com/markz/testApp/config/DataConfig.class index 0d18e8d..8ead929 100644 Binary files a/target/classes/com/markz/testApp/config/DataConfig.class and b/target/classes/com/markz/testApp/config/DataConfig.class differ diff --git a/target/classes/com/markz/testApp/controller/MyTestController.class b/target/classes/com/markz/testApp/controller/MyTestController.class index 25bd46d..03d77d4 100644 Binary files a/target/classes/com/markz/testApp/controller/MyTestController.class and b/target/classes/com/markz/testApp/controller/MyTestController.class differ diff --git a/target/classes/com/markz/testApp/mappers/UserDetailsMapper.class b/target/classes/com/markz/testApp/mappers/UserDetailsMapper.class new file mode 100644 index 0000000..1e3b5c0 Binary files /dev/null and b/target/classes/com/markz/testApp/mappers/UserDetailsMapper.class differ diff --git a/target/classes/com/markz/testApp/mappers/UserDetailsMapper.xml b/target/classes/com/markz/testApp/mappers/UserDetailsMapper.xml new file mode 100644 index 0000000..045655b --- /dev/null +++ b/target/classes/com/markz/testApp/mappers/UserDetailsMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.properties index 72227d8..2e04cb8 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.properties +++ b/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Apr 06 23:57:30 CDT 2015 +#Thu Apr 09 23:15:12 CDT 2015 version=0.0.1-SNAPSHOT groupId=SpringMVC m2e.projectName=SpringMVC diff --git a/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.xml index 995ddfa..c87adb2 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.xml +++ b/target/m2e-wtp/web-resources/META-INF/maven/SpringMVC/SpringMVC/pom.xml @@ -72,6 +72,15 @@ mybatis 3.2.8 - + + org.springframework + spring-jdbc + 4.1.4.RELEASE + + + mysql + mysql-connector-java + 5.1.35 + \ No newline at end of file