-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit e424730
Showing
28 changed files
with
748 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.gradle | ||
/build/ | ||
*/bin/ | ||
/bin/ | ||
*/out/ | ||
/out/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
|
||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.DS_Store | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
rebel.xml | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ | ||
|
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,5 @@ | ||
### gradle multi project | ||
|
||
- gradle-multi-core : common library (dao, dto) | ||
- gradle-multi-web : web application | ||
- gradle-multi-app : app application |
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,53 @@ | ||
//=================================================================// | ||
// gradle-multi ROOT | ||
//=================================================================// | ||
|
||
|
||
buildscript { | ||
ext { | ||
springBootVersion = '1.5.6.RELEASE' | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | ||
classpath('io.spring.gradle:dependency-management-plugin:1.0.0.RELEASE') | ||
} | ||
} | ||
|
||
|
||
subprojects { | ||
apply plugin: 'java' | ||
apply plugin: 'eclipse' | ||
apply plugin: 'idea' | ||
apply plugin: 'org.springframework.boot' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
task initSourceFolders { | ||
sourceSets*.java.srcDirs*.each { | ||
if( !it.exists() ) { | ||
it.mkdirs() | ||
} | ||
} | ||
|
||
sourceSets*.resources.srcDirs*.each { | ||
if( !it.exists() ) { | ||
it.mkdirs() | ||
} | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
compileOnly('org.projectlombok:lombok') | ||
testCompile("org.springframework.boot:spring-boot-starter-test") | ||
} | ||
|
||
} |
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,14 @@ | ||
use test_db; | ||
|
||
create table board( | ||
id int not null auto_increment, | ||
title varchar(100) not null, | ||
content text null, | ||
regdate datetime not null, | ||
primary key(id) | ||
); | ||
|
||
insert into board(title, content, regdate) values('title1', 'content1', now()); | ||
insert into board(title, content, regdate) values('title2', 'content2', now()); | ||
insert into board(title, content, regdate) values('title3', 'content3', now()); | ||
|
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,9 @@ | ||
//=================================================================// | ||
// gradle-multi-app | ||
//=================================================================// | ||
|
||
dependencies { | ||
compile project(':gradle-multi-core') | ||
compile('org.springframework.boot:spring-boot-starter-aop') | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
gradle-multi-app/src/main/java/com/example/app/GradleMultiAppMain.java
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,33 @@ | ||
package com.example.app; | ||
|
||
import com.example.app.service.BoardAppService; | ||
import com.example.core.board.dto.BoardDto; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.List; | ||
|
||
@SpringBootApplication | ||
@ComponentScan("com.example") | ||
public class GradleMultiAppMain { | ||
|
||
@Autowired | ||
private BoardAppService boardService; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(GradleMultiAppMain.class, args); | ||
} | ||
|
||
@PostConstruct | ||
public void run() { | ||
List<BoardDto> boardDtoList = boardService.selectList(); | ||
for (BoardDto boardDto : boardDtoList) { | ||
System.out.println("title = " + boardDto.getTitle()); | ||
System.out.println("content = " + boardDto.getContent()); | ||
} | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
gradle-multi-app/src/main/java/com/example/app/control/BoardAppController.java
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 @@ | ||
package com.example.app.control; | ||
|
||
/** | ||
* Created by yookeun on 2017. 10. 7.. | ||
*/ | ||
public class BoardAppController { | ||
} |
21 changes: 21 additions & 0 deletions
21
gradle-multi-app/src/main/java/com/example/app/service/BoardAppService.java
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,21 @@ | ||
package com.example.app.service; | ||
|
||
import com.example.core.board.dao.BoardDao; | ||
import com.example.core.board.dto.BoardDto; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by yookeun on 2017. 10. 7.. | ||
*/ | ||
|
||
@Service | ||
public class BoardAppService { | ||
@Autowired | ||
private BoardDao boardDao; | ||
public List<BoardDto> selectList() { | ||
return boardDao.selectList(); | ||
} | ||
} |
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,17 @@ | ||
spring: | ||
profiles: | ||
active: | ||
- ykkim | ||
datasource: | ||
type: com.zaxxer.hikari.HikariDataSource | ||
driver-class-name: com.mysql.jdbc.Driver | ||
url: jdbc:mysql://localhost:3306/test_db?useUnicode=true&characterEncoding=utf8 | ||
username: root | ||
password: 1234 | ||
hikari: | ||
maximum-pool-size: 10 | ||
max-lifetime: 30 | ||
|
||
security: | ||
basic: | ||
enabled: false |
33 changes: 33 additions & 0 deletions
33
gradle-multi-app/src/test/java/com/example/app/control/BoardAppControllerTest.java
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,33 @@ | ||
package com.example.app.control; | ||
|
||
import com.example.app.service.BoardAppService; | ||
import com.example.core.board.dto.BoardDto; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by yookeun on 2017. 10. 7.. | ||
*/ | ||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class BoardAppControllerTest { | ||
|
||
|
||
@Autowired | ||
private BoardAppService boardAppService; | ||
|
||
@Test | ||
public void board_list() { | ||
List<BoardDto> boardList = boardAppService.selectList(); | ||
for (BoardDto boardDto : boardList) { | ||
System.out.println("title = " + boardDto.getTitle()); | ||
System.out.println("content = " + boardDto.getContent()); | ||
} | ||
} | ||
|
||
} |
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,14 @@ | ||
//=================================================================// | ||
// gradle-multi-core | ||
//=================================================================// | ||
|
||
bootRepackage { | ||
enabled = false | ||
} | ||
|
||
dependencies { | ||
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1') | ||
runtime('mysql:mysql-connector-java') | ||
compile 'com.zaxxer:HikariCP:2.6.2' | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
gradle-multi-core/src/main/java/com/example/core/board/dao/BoardDao.java
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,21 @@ | ||
package com.example.core.board.dao; | ||
|
||
|
||
|
||
import java.util.List; | ||
|
||
import org.apache.ibatis.session.SqlSession; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.example.core.board.dto.BoardDto; | ||
|
||
@Repository | ||
public class BoardDao { | ||
@Autowired | ||
private SqlSession sqlSession; | ||
|
||
public List<BoardDto> selectList() { | ||
return sqlSession.selectList("boardMapper.selectList"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
gradle-multi-core/src/main/java/com/example/core/board/dto/BoardDto.java
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,11 @@ | ||
package com.example.core.board.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class BoardDto { | ||
private int id; | ||
private String title; | ||
private String content; | ||
private String regdate; | ||
} |
42 changes: 42 additions & 0 deletions
42
gradle-multi-core/src/main/java/com/example/core/config/MyBatisConfig.java
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,42 @@ | ||
package com.example.core.config; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.mybatis.spring.SqlSessionFactoryBean; | ||
import org.mybatis.spring.SqlSessionTemplate; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.DefaultResourceLoader; | ||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
@Configuration | ||
@EnableTransactionManagement | ||
@ComponentScan("com.example") | ||
public class MyBatisConfig { | ||
|
||
// @Autowired | ||
// private DataSource dataSource; | ||
|
||
@Bean | ||
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { | ||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); | ||
bean.setDataSource(dataSource); | ||
bean.setConfigLocation(new DefaultResourceLoader().getResource("classpath:mybatis-config.xml")); | ||
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml")); | ||
return bean.getObject(); | ||
} | ||
|
||
@Bean | ||
public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) { | ||
return new SqlSessionTemplate(sqlSessionFactory); | ||
} | ||
|
||
@Bean | ||
public DataSourceTransactionManager txManager(DataSource dataSource) { | ||
return new DataSourceTransactionManager(dataSource); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
gradle-multi-core/src/main/resources/mapper/boardMapper.xml
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
<mapper namespace="boardMapper"> | ||
|
||
<select id="selectList" resultType="boardDto" > | ||
SELECT /* + boardMapper.selectList + */ | ||
id, title, content, regdate FROM board | ||
</select> | ||
|
||
</mapper> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> | ||
<configuration> | ||
|
||
<settings> | ||
<setting name="cacheEnabled" value="false"/> | ||
<setting name="lazyLoadingEnabled" value="true"/> | ||
<setting name="aggressiveLazyLoading" value="true"/> | ||
<setting name="useGeneratedKeys" value="true"/> | ||
<setting name="defaultExecutorType" value="SIMPLE"/> | ||
<setting name="defaultStatementTimeout" value="600"/> | ||
<setting name="multipleResultSetsEnabled" value="true" /> | ||
<setting name="useColumnLabel" value="true" /> | ||
<setting name="safeRowBoundsEnabled" value="false" /> | ||
<setting name="mapUnderscoreToCamelCase" value="true" /> | ||
</settings> | ||
|
||
|
||
<!-- Model 객체 Alias --> | ||
<typeAliases> | ||
<typeAlias alias="boardDto" type="com.example.core.board.dto.BoardDto"></typeAlias> | ||
</typeAliases> | ||
</configuration> |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID"> | ||
<display-name>gradle-multi-web</display-name> | ||
<welcome-file-list> | ||
<welcome-file>index.html</welcome-file> | ||
<welcome-file>index.htm</welcome-file> | ||
<welcome-file>index.jsp</welcome-file> | ||
<welcome-file>default.html</welcome-file> | ||
<welcome-file>default.htm</welcome-file> | ||
<welcome-file>default.jsp</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
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 @@ | ||
//=================================================================// | ||
// gradle-multi-web | ||
//=================================================================// | ||
|
||
apply plugin: 'war' | ||
|
||
dependencies { | ||
compile project(':gradle-multi-core') | ||
|
||
providedCompile 'javax.servlet:javax.servlet-api:3.1.0' | ||
compile 'javax.servlet:jstl:1.2' | ||
compile('org.springframework.boot:spring-boot-starter-web') | ||
compile('org.springframework.boot:spring-boot-starter-security') | ||
testCompile('org.springframework.security:spring-security-test') | ||
} |
Oops, something went wrong.