Skip to content

Commit

Permalink
Update Spring pom.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
yiming187 committed Mar 12, 2016
1 parent b3309f1 commit f698934
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text=auto
20 changes: 15 additions & 5 deletions apollo-configserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,32 @@
</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>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
8 changes: 8 additions & 0 deletions apollo-metaserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
12 changes: 10 additions & 2 deletions apollo-portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

@SpringBootApplication
public class PortalApplication {

public static void main(String[] args) throws Exception {
SpringApplication.run(PortalApplication.class, args);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ctrip.apollo.portal.entities;
package com.ctrip.apollo.portal.domain;

import java.io.Serializable;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 1 addition & 2 deletions apollo-portal/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion apollo-portal/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit f698934

Please sign in to comment.