From f6989346a07fa7884f6f7cb0b79cc46fd4d54b85 Mon Sep 17 00:00:00 2001 From: Yiming Liu Date: Sun, 13 Mar 2016 00:11:37 +0800 Subject: [PATCH] Update Spring pom.xml --- .gitattributes | 1 + apollo-configserver/pom.xml | 20 ++- apollo-metaserver/pom.xml | 8 + apollo-portal/pom.xml | 12 +- .../apollo/portal/PortalApplication.java | 1 + .../portal/controller/SampleController.java | 14 -- .../portal/{entities => domain}/App.java | 2 +- .../{repository => domain}/AppRepository.java | 4 +- .../apollo/portal/service/AppService.java | 31 ++++ .../{controller => web}/AppController.java | 29 ++-- .../src/main/resources/application.properties | 3 +- .../portal/repository/AppRepositoryTest.java | 3 +- .../src/test/resources/application.properties | 1 - pom.xml | 147 +++++++++++++----- 14 files changed, 196 insertions(+), 80 deletions(-) create mode 100644 .gitattributes delete mode 100644 apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/SampleController.java rename apollo-portal/src/main/java/com/ctrip/apollo/portal/{entities => domain}/App.java (97%) rename apollo-portal/src/main/java/com/ctrip/apollo/portal/{repository => domain}/AppRepository.java (74%) create mode 100644 apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java rename apollo-portal/src/main/java/com/ctrip/apollo/portal/{controller => web}/AppController.java (62%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..af19312d146 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +text=auto \ No newline at end of file diff --git a/apollo-configserver/pom.xml b/apollo-configserver/pom.xml index 995a61e0f9a..0c1d79ba3ef 100644 --- a/apollo-configserver/pom.xml +++ b/apollo-configserver/pom.xml @@ -21,17 +21,19 @@ org.springframework.boot - spring-boot-starter-test - test + spring-boot-starter-data-jpa - org.springframework.boot - spring-boot-starter-data-jpa + org.springframework.data + spring-data-redis + + + redis.clients + jedis com.h2database h2 - test mysql @@ -39,4 +41,12 @@ runtime + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/apollo-metaserver/pom.xml b/apollo-metaserver/pom.xml index e419dbb8af2..86a82324ccf 100644 --- a/apollo-metaserver/pom.xml +++ b/apollo-metaserver/pom.xml @@ -25,4 +25,12 @@ test + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/apollo-portal/pom.xml b/apollo-portal/pom.xml index 62c1f2045aa..dc8b5234d84 100644 --- a/apollo-portal/pom.xml +++ b/apollo-portal/pom.xml @@ -21,8 +21,8 @@ org.springframework.boot - spring-boot-starter-test - test + spring-boot-devtools + true org.springframework.boot @@ -38,4 +38,12 @@ runtime + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java index 2a7c5828a6a..7597248a162 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java @@ -5,6 +5,7 @@ @SpringBootApplication public class PortalApplication { + public static void main(String[] args) throws Exception { SpringApplication.run(PortalApplication.class, args); } diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/SampleController.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/SampleController.java deleted file mode 100644 index 37e4dc8784b..00000000000 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/SampleController.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.ctrip.apollo.portal.controller; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class SampleController { - - @RequestMapping("") - public String home() { - return "Hello World!"; - } -} diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/entities/App.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/App.java similarity index 97% rename from apollo-portal/src/main/java/com/ctrip/apollo/portal/entities/App.java rename to apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/App.java index 23db542263c..38cdbd882bc 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/entities/App.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/App.java @@ -1,4 +1,4 @@ -package com.ctrip.apollo.portal.entities; +package com.ctrip.apollo.portal.domain; import java.io.Serializable; import java.util.Date; diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/AppRepository.java similarity index 74% rename from apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java rename to apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/AppRepository.java index ce1c4eca6ac..76e9029ef52 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/domain/AppRepository.java @@ -1,11 +1,9 @@ -package com.ctrip.apollo.portal.repository; +package com.ctrip.apollo.portal.domain; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; -import com.ctrip.apollo.portal.entities.App; - public interface AppRepository extends CrudRepository { Page findAll(Pageable pageable); diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java new file mode 100644 index 00000000000..d92b1cbf4ea --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java @@ -0,0 +1,31 @@ +package com.ctrip.apollo.portal.service; + +import java.util.Date; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import com.ctrip.apollo.portal.domain.App; +import com.ctrip.apollo.portal.domain.AppRepository; + +@Service +public class AppService { + + @Autowired + private AppRepository appRepository; + + public App detail(String appId) { + return appRepository.findOne(appId); + } + + public Page list(Pageable pageable) { + return appRepository.findAll(pageable); + } + + public App save(App app) { + app.setCreateTimestamp(new Date()); + return appRepository.save(app); + } +} diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/web/AppController.java similarity index 62% rename from apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java rename to apollo-portal/src/main/java/com/ctrip/apollo/portal/web/AppController.java index b238603a0e3..a909e053b2d 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/web/AppController.java @@ -1,33 +1,36 @@ -package com.ctrip.apollo.portal.controller; - -import java.util.Date; +package com.ctrip.apollo.portal.web; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.ctrip.apollo.portal.entities.App; -import com.ctrip.apollo.portal.repository.AppRepository; +import com.ctrip.apollo.portal.domain.App; +import com.ctrip.apollo.portal.service.AppService; @RestController @RequestMapping("/apps") public class AppController { @Autowired - private AppRepository appRepository; - - @RequestMapping("") - public Page list(@PageableDefault(size = 50) Pageable pageable) { - return appRepository.findAll(pageable); - } + private AppService appService; @RequestMapping(value = "", method = RequestMethod.POST) public App create(App app) { - app.setCreateTimestamp(new Date()); - return appRepository.save(app); + return appService.save(app); + } + + @RequestMapping("/{appid}") + public App detail(@PathVariable String appId) { + return appService.detail(appId); + } + + @RequestMapping("") + public Page list(@PageableDefault(size = 50) Pageable pageable) { + return appService.list(pageable); } } diff --git a/apollo-portal/src/main/resources/application.properties b/apollo-portal/src/main/resources/application.properties index 30d8c0d80a6..d0376dd0060 100644 --- a/apollo-portal/src/main/resources/application.properties +++ b/apollo-portal/src/main/resources/application.properties @@ -1,4 +1,3 @@ -spring.datasource.url = jdbc:h2:file:~/fxapolloportaldb +spring.datasource.url = jdbc:h2:file:~/fxapolloportaldb;DB_CLOSE_ON_EXIT=FALSE spring.datasource.username = sa spring.datasource.password = sa -spring.datasource.driver-class-name = org.h2.Driver diff --git a/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java b/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java index 467361790b9..96c0e34d8cd 100644 --- a/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java +++ b/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java @@ -10,7 +10,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.ctrip.apollo.portal.PortalApplicationTestConfiguration; -import com.ctrip.apollo.portal.entities.App; +import com.ctrip.apollo.portal.domain.App; +import com.ctrip.apollo.portal.domain.AppRepository; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = PortalApplicationTestConfiguration.class) diff --git a/apollo-portal/src/test/resources/application.properties b/apollo-portal/src/test/resources/application.properties index 46dc4f37601..e2efcb2fc76 100644 --- a/apollo-portal/src/test/resources/application.properties +++ b/apollo-portal/src/test/resources/application.properties @@ -2,4 +2,3 @@ spring.datasource.url = jdbc:h2:file:~/fxapolloportaldb;DB_CLOSE_ON_EXIT=FALSE spring.datasource.username = sa spring.datasource.password = sa -spring.h2.console.enabled = true \ No newline at end of file diff --git a/pom.xml b/pom.xml index 023918b724f..4a4583622d2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,57 @@ 0.0.1 Apollo pom + Ctrip Configuration Center + https://github.com/ctripcorp/apollo + + Ctrip, Inc. + http://www.ctrip.com + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + https://github.com/ctripcorp/apollo + + + + yiming187 + Billy(Yiming) Liu + liuyiming.vip at gmail.com + Ctrip, Inc. + http://www.ctrip.com + + Developer + + + + nobodyiam + Jason(Shun) Song + nobodyiam at gmail.com + Ctrip, Inc. + http://www.ctrip.com + + Developer + + + + lepdou + Le Zhang + lepdou at gmail.com + Ctrip, Inc. + http://www.ctrip.com + + Developer + + + + + utf-8 + 1.8 + apollo-core apollo-metaserver @@ -28,13 +79,6 @@ 1.4.4 - - org.springframework.cloud - spring-cloud-starter-parent - Angel.SR6 - pom - import - mysql mysql-connector-java @@ -46,36 +90,67 @@ h2 1.4.191 + + + org.springframework.boot + spring-boot-starter-parent + 1.3.3.RELEASE + pom + import + + + org.springframework.cloud + spring-cloud-config + 1.1.0.M5 + pom + import + + + + org.springframework.boot + spring-boot-starter-test + test + + - - - maven-compiler-plugin - 3.5.1 - - ${java.source} - ${java.target} - - - - maven-source-plugin - 3.0.0 - - - attach-sources - - jar - - - - - - org.springframework.boot - spring-boot-maven-plugin - 1.3.3.RELEASE - - + + + + maven-compiler-plugin + 3.5.1 + + ${java.source} + ${java.target} + + + + maven-source-plugin + 3.0.0 + + + attach-sources + + jar + + + + + + org.springframework.boot + spring-boot-maven-plugin + 1.3.3.RELEASE + + + + repackage + + + + + + @@ -127,9 +202,5 @@ - - utf-8 - 1.8 -