-
Notifications
You must be signed in to change notification settings - Fork 0
park7777/이슈이름 : Set up mybatis. #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beanbroker
wants to merge
1
commit into
master
Choose a base branch
from
park7777
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,48 @@ | ||
| <factorypath> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-web/1.5.2.RELEASE/spring-boot-starter-web-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter/1.5.2.RELEASE/spring-boot-starter-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot/1.5.2.RELEASE/spring-boot-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-autoconfigure/1.5.2.RELEASE/spring-boot-autoconfigure-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-logging/1.5.2.RELEASE/spring-boot-starter-logging-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/jcl-over-slf4j/1.7.5/jcl-over-slf4j-1.7.5.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/jul-to-slf4j/1.7.5/jul-to-slf4j-1.7.5.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/log4j-over-slf4j/1.7.5/log4j-over-slf4j-1.7.5.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-tomcat/1.5.2.RELEASE/spring-boot-starter-tomcat-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/hibernate/hibernate-validator/5.3.4.Final/hibernate-validator-5.3.4.Final.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-web/4.3.7.RELEASE/spring-web-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-webmvc/4.3.7.RELEASE/spring-webmvc-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/ch/qos/logback/logback-core/1.0.13/logback-core-1.0.13.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/mybatis/spring/boot/mybatis-spring-boot-starter/1.1.1/mybatis-spring-boot-starter-1.1.1.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/1.1.1/mybatis-spring-boot-autoconfigure-1.1.1.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/mybatis/mybatis/3.4.0/mybatis-3.4.0.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/mybatis/mybatis-spring/1.3.0/mybatis-spring-1.3.0.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-jdbc/1.5.2.RELEASE/spring-boot-starter-jdbc-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/tomcat-jdbc/8.5.11/tomcat-jdbc-8.5.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/tomcat-juli/8.5.11/tomcat-juli-8.5.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-jdbc/4.3.7.RELEASE/spring-jdbc-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-tx/4.3.7.RELEASE/spring-tx-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-test/3.2.3.RELEASE/spring-test-3.2.3.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/junit/junit/4.11/junit-4.11.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-configuration-processor/1.5.2.RELEASE/spring-boot-configuration-processor-1.5.2.RELEASE.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="VARJAR" id="M2_REPO/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar" enabled="true" runInBatchMode="false"/> | ||
| <factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/> | ||
| </factorypath> |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/net/neo/sample/controller/SampleController.java
This file contains hidden or 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,18 @@ | ||
| package net.neo.sample.controller; | ||
|
|
||
| import org.springframework.context.annotation.ComponentScan; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @ComponentScan | ||
| @RestController | ||
| public class SampleController { | ||
|
|
||
| @RequestMapping("/sample") | ||
| public String home() { | ||
|
|
||
| return "Hello World!"; | ||
|
|
||
| } | ||
|
|
||
| } |
This file contains hidden or 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,18 @@ | ||
| package net.neo.sample.dao; | ||
|
|
||
| import javax.annotation.Resource; | ||
|
|
||
| import org.apache.ibatis.session.SqlSessionFactory; | ||
| import org.mybatis.spring.support.SqlSessionDaoSupport; | ||
|
|
||
| public class NeoDao extends SqlSessionDaoSupport { | ||
|
|
||
| protected NeoDao() { | ||
|
|
||
| } | ||
|
|
||
| @Resource(name = "sqlSessionFactory") | ||
| public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { | ||
| super.setSqlSessionFactory(sqlSessionFactory); | ||
| } | ||
| } |
This file contains hidden or 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,43 @@ | ||
| package net.neo.sample.dto; | ||
|
|
||
| import java.lang.reflect.Field; | ||
| import java.lang.reflect.Modifier; | ||
|
|
||
| public class NeoDto { | ||
|
|
||
| @Override | ||
| public String toString() { | ||
|
|
||
| StringBuilder sb = new StringBuilder(); | ||
|
|
||
| try { | ||
|
|
||
| Field[] allFields = this.getClass().getDeclaredFields(); | ||
|
|
||
| for (Field field : allFields) { | ||
|
|
||
| if (Modifier.isPrivate(field.getModifiers())) { | ||
|
|
||
| field.setAccessible(true); | ||
|
|
||
| String fieldName = field.getName(); | ||
| Object fieldValue = field.get(this); | ||
|
|
||
| if (fieldValue != null) { | ||
|
|
||
| sb.append(fieldName.toUpperCase()).append("=").append("[").append(fieldValue).append("] "); | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| } catch (IllegalArgumentException e) { | ||
| e.printStackTrace(); | ||
| } catch (IllegalAccessException e) { | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| return sb.toString().trim(); | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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,29 @@ | ||
| package net.neo.sample.spring.boot; | ||
|
|
||
| import org.mybatis.spring.annotation.MapperScan; | ||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.context.annotation.ComponentScan; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
|
||
| import net.neo.sample.controller.SampleController; | ||
| import net.neo.sample.user.controller.UserController; | ||
|
|
||
| @Configuration | ||
| @EnableAutoConfiguration | ||
| @ComponentScan | ||
| @SpringBootApplication | ||
| @EnableScheduling | ||
| @MapperScan("net.neo.sample") | ||
|
|
||
| @ComponentScan(basePackageClasses=SampleController.class) | ||
| @ComponentScan(basePackageClasses=UserController.class) | ||
| public class Application { | ||
|
|
||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| SpringApplication.run(Application.class, args); | ||
| } | ||
| } |
This file contains hidden or 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,51 @@ | ||
| package net.neo.sample.spring.boot; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import javax.annotation.PostConstruct; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.util.StopWatch; | ||
|
|
||
| import net.neo.sample.spring.boot.mapper.TestMapper; | ||
|
|
||
| @Component | ||
| public class Timer { | ||
| Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| private AtomicInteger loopCounter = new AtomicInteger(); | ||
|
|
||
| @Autowired | ||
| private StopWatch watch; | ||
|
|
||
| @Autowired | ||
| private TestMapper testMapper; | ||
|
|
||
| @Value("${spring.task.name}") | ||
| private String taskNamePrefix; | ||
|
|
||
| @Value("${spring.timerName}") | ||
| private String timerName; | ||
|
|
||
| @PostConstruct | ||
| public void init() { | ||
| logger.info("{} init", timerName); | ||
| watch.start(); | ||
| } | ||
|
|
||
| @Scheduled(fixedDelayString = "${spring.task.fixedDelay}") | ||
| public void tick() throws InterruptedException{ | ||
| watch.stop(); | ||
| logger.info(testMapper.getValueFromDatabase()); | ||
| String taskName = taskNamePrefix + "-" + String.valueOf(loopCounter.getAndIncrement()); | ||
| watch.start(taskName); | ||
| } | ||
|
|
||
| @Bean | ||
| public StopWatch watch() { | ||
| return new StopWatch(); | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
src/main/java/net/neo/sample/spring/boot/mapper/TestMapper.java
This file contains hidden or 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,5 @@ | ||
| package net.neo.sample.spring.boot.mapper; | ||
|
|
||
| public interface TestMapper { | ||
| public String getValueFromDatabase(); | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/main/java/net/neo/sample/user/controller/UserController.java
This file contains hidden or 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 @@ | ||
| package net.neo.sample.user.controller; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import javax.annotation.Resource; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import net.neo.sample.user.dto.UserDto; | ||
| import net.neo.sample.user.service.UserService; | ||
|
|
||
| @RestController | ||
| public class UserController { | ||
|
|
||
| @Autowired | ||
| private UserService userService; | ||
|
|
||
| @RequestMapping("/user") | ||
| public String home() { | ||
|
|
||
| return "Hello World!"; | ||
|
|
||
| } | ||
|
|
||
| @RequestMapping("/userlist") | ||
| public Map<String, Object> userList() { | ||
|
|
||
| UserDto userDto = new UserDto(); | ||
|
|
||
| List<UserDto> userInfoList = userService.selectUserInfoList(userDto); | ||
|
|
||
| Map<String, Object> dataMap = new HashMap<String, Object>(); | ||
| dataMap.put("data", userInfoList); | ||
| return dataMap; | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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,17 @@ | ||
| package net.neo.sample.user.dao; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import net.neo.sample.dao.NeoDao; | ||
| import net.neo.sample.user.dto.UserDto; | ||
|
|
||
| @Repository | ||
| public class UserDao extends NeoDao { | ||
|
|
||
| public List<UserDto> selectUserInfoList(UserDto userDto) { | ||
|
|
||
| return getSqlSession().selectList("net.neo.mapper.user.selectUserInfoList", userDto); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull request 내용에 해당 라이브러리에 대한 내용과 필요성을 추가해주세요
해당 내용은 @it2seiyon 님의 리뷰가 필요합니다. pom 파일 담당자이니까요 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ConfigurationProperties 을 사용할 때는 spring-boot-configuration-processor를 클래스패스에 설정하는 것을 권장한다는 정보를 발견하였습니다.
정보는 아래와 같습니다.
STS 에서 간단하게 스프링부트 애플리케이션 생성하기
STS 에서 부트 애플리케이션을 실행하고 디버깅하기
STS Properties editor를 이용해서 설정프로퍼타이즈 편집하기
@ConfigurationProperties를 사용하는 코드에서 설정프로퍼타이즈 편집하기