Commit f6989346 by Yiming Liu

Update Spring pom.xml

parent b3309f1a
text=auto
\ No newline at end of file
...@@ -21,17 +21,19 @@ ...@@ -21,17 +21,19 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
...@@ -39,4 +41,12 @@ ...@@ -39,4 +41,12 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -25,4 +25,12 @@ ...@@ -25,4 +25,12 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-devtools</artifactId>
<scope>test</scope> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -38,4 +38,12 @@ ...@@ -38,4 +38,12 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class PortalApplication { public class PortalApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
SpringApplication.run(PortalApplication.class, args); SpringApplication.run(PortalApplication.class, args);
} }
......
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!";
}
}
package com.ctrip.apollo.portal.entities; package com.ctrip.apollo.portal.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
......
package com.ctrip.apollo.portal.repository; package com.ctrip.apollo.portal.domain;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import com.ctrip.apollo.portal.entities.App;
public interface AppRepository extends CrudRepository<App, String> { public interface AppRepository extends CrudRepository<App, String> {
Page<App> findAll(Pageable pageable); Page<App> findAll(Pageable pageable);
......
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);
}
}
package com.ctrip.apollo.portal.controller; package com.ctrip.apollo.portal.web;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ctrip.apollo.portal.entities.App; import com.ctrip.apollo.portal.domain.App;
import com.ctrip.apollo.portal.repository.AppRepository; import com.ctrip.apollo.portal.service.AppService;
@RestController @RestController
@RequestMapping("/apps") @RequestMapping("/apps")
public class AppController { public class AppController {
@Autowired @Autowired
private AppRepository appRepository; private AppService appService;
@RequestMapping("")
public Page<App> list(@PageableDefault(size = 50) Pageable pageable) {
return appRepository.findAll(pageable);
}
@RequestMapping(value = "", method = RequestMethod.POST) @RequestMapping(value = "", method = RequestMethod.POST)
public App create(App app) { public App create(App app) {
app.setCreateTimestamp(new Date()); return appService.save(app);
return appRepository.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);
} }
} }
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.username = sa
spring.datasource.password = sa spring.datasource.password = sa
spring.datasource.driver-class-name = org.h2.Driver
...@@ -10,7 +10,8 @@ import org.springframework.boot.test.SpringApplicationConfiguration; ...@@ -10,7 +10,8 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.ctrip.apollo.portal.PortalApplicationTestConfiguration; 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) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PortalApplicationTestConfiguration.class) @SpringApplicationConfiguration(classes = PortalApplicationTestConfiguration.class)
......
...@@ -2,4 +2,3 @@ spring.datasource.url = jdbc:h2:file:~/fxapolloportaldb;DB_CLOSE_ON_EXIT=FALSE ...@@ -2,4 +2,3 @@ spring.datasource.url = jdbc:h2:file:~/fxapolloportaldb;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username = sa spring.datasource.username = sa
spring.datasource.password = sa spring.datasource.password = sa
spring.h2.console.enabled = true
\ No newline at end of file
...@@ -7,6 +7,57 @@ ...@@ -7,6 +7,57 @@
<version>0.0.1</version> <version>0.0.1</version>
<name>Apollo</name> <name>Apollo</name>
<packaging>pom</packaging> <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> <modules>
<module>apollo-core</module> <module>apollo-core</module>
<module>apollo-metaserver</module> <module>apollo-metaserver</module>
...@@ -29,13 +80,6 @@ ...@@ -29,13 +80,6 @@
</dependency> </dependency>
<!--third party --> <!--third party -->
<dependency> <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> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version> <version>5.1.38</version>
...@@ -46,36 +90,67 @@ ...@@ -46,36 +90,67 @@
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>1.4.191</version> <version>1.4.191</version>
</dependency> </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> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<plugins> <pluginManagement>
<plugin> <plugins>
<artifactId>maven-compiler-plugin</artifactId> <plugin>
<version>3.5.1</version> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>3.5.1</version>
<source>${java.source}</source> <configuration>
<target>${java.target}</target> <source>${java.source}</source>
</configuration> <target>${java.target}</target>
</plugin> </configuration>
<plugin> </plugin>
<artifactId>maven-source-plugin</artifactId> <plugin>
<version>3.0.0</version> <artifactId>maven-source-plugin</artifactId>
<executions> <version>3.0.0</version>
<execution> <executions>
<id>attach-sources</id> <execution>
<goals> <id>attach-sources</id>
<goal>jar</goal> <goals>
</goals> <goal>jar</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.springframework.boot</groupId> <plugin>
<artifactId>spring-boot-maven-plugin</artifactId> <groupId>org.springframework.boot</groupId>
<version>1.3.3.RELEASE</version> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> <version>1.3.3.RELEASE</version>
</plugins> <executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
<profiles> <profiles>
<profile> <profile>
...@@ -127,9 +202,5 @@ ...@@ -127,9 +202,5 @@
</snapshots> </snapshots>
</repository> </repository>
</repositories> </repositories>
<properties>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
</project> </project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment