Browse Source

Update Spring pom.xml

Yiming Liu 9 years ago
parent
commit
f6989346a0

+ 1 - 0
.gitattributes

@@ -0,0 +1 @@
+text=auto

+ 15 - 5
apollo-configserver/pom.xml

@@ -21,17 +21,19 @@
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-data-jpa</artifactId>
+			<groupId>org.springframework.data</groupId>
+			<artifactId>spring-data-redis</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
 		</dependency>
 		<dependency>
 			<groupId>com.h2database</groupId>
 			<artifactId>h2</artifactId>
-			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>mysql</groupId>
@@ -39,4 +41,12 @@
 			<scope>runtime</scope>
 		</dependency>
 	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
 </project>

+ 8 - 0
apollo-metaserver/pom.xml

@@ -25,4 +25,12 @@
 			<scope>test</scope>
 		</dependency>
 	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
 </project>

+ 10 - 2
apollo-portal/pom.xml

@@ -21,8 +21,8 @@
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
+			<artifactId>spring-boot-devtools</artifactId>
+			<optional>true</optional>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
@@ -38,4 +38,12 @@
 			<scope>runtime</scope>
 		</dependency>
 	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
 </project>

+ 1 - 0
apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java

@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
 public class PortalApplication {
+  
   public static void main(String[] args) throws Exception {
     SpringApplication.run(PortalApplication.class, args);
   }

+ 0 - 14
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/SampleController.java

@@ -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!";
-  }
-}

+ 1 - 1
apollo-portal/src/main/java/com/ctrip/apollo/portal/entities/App.java → 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;

+ 1 - 3
apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java → 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<App, String> {
 
   Page<App> findAll(Pageable pageable);

+ 31 - 0
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<App> list(Pageable pageable) {
+    return appRepository.findAll(pageable);
+  }
+
+  public App save(App app) {
+    app.setCreateTimestamp(new Date());
+    return appRepository.save(app);
+  }
+}

+ 16 - 13
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java → 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<App> 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<App> list(@PageableDefault(size = 50) Pageable pageable) {
+    return appService.list(pageable);
   }
 }

+ 1 - 2
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

+ 2 - 1
apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java

@@ -10,7 +10,8 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
 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)

+ 0 - 1
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

+ 109 - 38
pom.xml

@@ -7,6 +7,57 @@
 	<version>0.0.1</version>
 	<name>Apollo</name>
 	<packaging>pom</packaging>
+	<description>Ctrip Configuration Center</description>
+	<url>https://github.com/ctripcorp/apollo</url>
+	<organization>
+		<name>Ctrip, Inc.</name>
+		<url>http://www.ctrip.com</url>
+	</organization>
+	<licenses>
+		<license>
+			<name>Apache License, Version 2.0</name>
+			<url>http://www.apache.org/licenses/LICENSE-2.0</url>
+		</license>
+	</licenses>
+	<scm>
+		<url>https://github.com/ctripcorp/apollo</url>
+	</scm>
+	<developers>
+		<developer>
+			<id>yiming187</id>
+			<name>Billy(Yiming) Liu</name>
+			<email>liuyiming.vip at gmail.com</email>
+			<organization>Ctrip, Inc.</organization>
+			<organizationUrl>http://www.ctrip.com</organizationUrl>
+			<roles>
+				<role>Developer</role>
+			</roles>
+		</developer>
+		<developer>
+			<id>nobodyiam</id>
+			<name>Jason(Shun) Song</name>
+			<email>nobodyiam at gmail.com</email>
+			<organization>Ctrip, Inc.</organization>
+			<organizationUrl>http://www.ctrip.com</organizationUrl>
+			<roles>
+				<role>Developer</role>
+			</roles>
+		</developer>
+		<developer>
+			<id>lepdou</id>
+			<name>Le Zhang</name>
+			<email>lepdou at gmail.com</email>
+			<organization>Ctrip, Inc.</organization>
+			<organizationUrl>http://www.ctrip.com</organizationUrl>
+			<roles>
+				<role>Developer</role>
+			</roles>
+		</developer>
+	</developers>
+	<properties>
+		<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
+		<java.version>1.8</java.version>
+	</properties>
 	<modules>
 		<module>apollo-core</module>
 		<module>apollo-metaserver</module>
@@ -28,13 +79,6 @@
 				<version>1.4.4</version>
 			</dependency>
 			<!--third party -->
-			<dependency>
-				<groupId>org.springframework.cloud</groupId>
-				<artifactId>spring-cloud-starter-parent</artifactId>
-				<version>Angel.SR6</version>
-				<type>pom</type>
-				<scope>import</scope>
-			</dependency>
 			<dependency>
 				<groupId>mysql</groupId>
 				<artifactId>mysql-connector-java</artifactId>
@@ -46,36 +90,67 @@
 				<artifactId>h2</artifactId>
 				<version>1.4.191</version>
 			</dependency>
+			<!-- declare Spring BOMs in order -->
+			<dependency>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-starter-parent</artifactId>
+				<version>1.3.3.RELEASE</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
+			<dependency>
+				<groupId>org.springframework.cloud</groupId>
+				<artifactId>spring-cloud-config</artifactId>
+				<version>1.1.0.M5</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
 		</dependencies>
 	</dependencyManagement>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
 	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.5.1</version>
-				<configuration>
-					<source>${java.source}</source>
-					<target>${java.target}</target>
-				</configuration>
-			</plugin>
-			<plugin>
-				<artifactId>maven-source-plugin</artifactId>
-				<version>3.0.0</version>
-				<executions>
-					<execution>
-						<id>attach-sources</id>
-						<goals>
-							<goal>jar</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-				<version>1.3.3.RELEASE</version>
-			</plugin>
-		</plugins>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<artifactId>maven-compiler-plugin</artifactId>
+					<version>3.5.1</version>
+					<configuration>
+						<source>${java.source}</source>
+						<target>${java.target}</target>
+					</configuration>
+				</plugin>
+				<plugin>
+					<artifactId>maven-source-plugin</artifactId>
+					<version>3.0.0</version>
+					<executions>
+						<execution>
+							<id>attach-sources</id>
+							<goals>
+								<goal>jar</goal>
+							</goals>
+						</execution>
+					</executions>
+				</plugin>
+				<plugin>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-maven-plugin</artifactId>
+					<version>1.3.3.RELEASE</version>
+					<executions>
+						<execution>
+							<goals>
+								<goal>repackage</goal>
+							</goals>
+						</execution>
+					</executions>
+				</plugin>
+			</plugins>
+		</pluginManagement>
 	</build>
 	<profiles>
 		<profile>
@@ -127,9 +202,5 @@
 			</snapshots>
 		</repository>
 	</repositories>
-	<properties>
-		<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
-		<java.version>1.8</java.version>
-	</properties>
 </project>