Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
0d9d990c
Commit
0d9d990c
authored
Apr 07, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #63 from yiming187/json_update
Force REST return json format
parents
7bc2ffa8
05f3a9c8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
107 deletions
+142
-107
WebMvcConfig.java
...om/ctrip/apollo/adminservice/controller/WebMvcConfig.java
+7
-0
import.sql
apollo-adminservice/src/test/resources/import.sql
+14
-14
pom.xml
apollo-biz/pom.xml
+4
-9
Release.java
...iz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
+2
-0
import.sql
apollo-biz/src/test/resources/import.sql
+10
-10
pom.xml
apollo-configservice/pom.xml
+74
-74
WebMvcConfig.java
...m/ctrip/apollo/configservice/controller/WebMvcConfig.java
+31
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/WebMvcConfig.java
View file @
0d9d990c
...
...
@@ -5,7 +5,9 @@ import java.util.List;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
...
...
@@ -21,4 +23,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
argumentResolvers
.
add
(
resolver
);
}
@Override
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
configurer
.
ignoreAcceptHeader
(
true
).
defaultContentType
(
MediaType
.
APPLICATION_JSON
);
}
}
apollo-adminservice/src/test/resources/import.sql
View file @
0d9d990c
...
...
@@ -11,21 +11,21 @@ INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'cluster3'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'fxhermesproducer'
,
'default'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'ap
ollo-config-service
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'ap
ollo-admin-service
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'ap
ollo-portal-service
'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'
fx-hermes-producer
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'
application
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'ap
ollo-config-service
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'
fx-hermes-producer
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'ap
ollo-admin-service
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'ap
ollo-portal
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'
fx-hermes-producer
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'
application
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'
application
'
);
INSERT
INTO
Item
(
Namespace
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
Namespace
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k2'
,
'v2'
,
'comment2'
);
INSERT
INTO
Item
(
Namespace
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
2
,
'k3'
,
'v3'
,
'comment3'
);
INSERT
INTO
Item
(
Namespace
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
5
,
'k3'
,
'v4'
,
'comment4'
);
INSERT
INTO
Item
(
Group
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
Group
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k2'
,
'v2'
,
'comment2'
);
INSERT
INTO
Item
(
Group
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
2
,
'k3'
,
'v3'
,
'comment3'
);
INSERT
INTO
Item
(
Group
Id
,
`Key`
,
Value
,
Comment
)
VALUES
(
5
,
'k3'
,
'v4'
,
'comment4'
);
INSERT
INTO
`RELEASE`
(
Name
,
Comment
,
AppId
,
ClusterName
,
NamespaceName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'ap
ollo-config-service
'
,
'{"k1":"v1"}'
);
INSERT
INTO
`RELEASE`
(
Name
,
Comment
,
AppId
,
ClusterName
,
NamespaceName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'ap
plication
'
,
'{"k1":"v1"}'
);
apollo-biz/pom.xml
View file @
0d9d990c
...
...
@@ -20,6 +20,10 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
...
...
@@ -34,14 +38,5 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>
ctrip
</id>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
View file @
0d9d990c
...
...
@@ -3,6 +3,7 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Lob
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
...
...
@@ -11,6 +12,7 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@Table
(
name
=
"\"Release\""
)
@SQLDelete
(
sql
=
"Update Release set isDeleted = 'false' where id = ?"
)
@Where
(
clause
=
"isDeleted = 'false'"
)
public
class
Release
extends
BaseEntity
{
...
...
apollo-biz/src/test/resources/import.sql
View file @
0d9d990c
...
...
@@ -11,21 +11,21 @@ INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'cluster3'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'fxhermesproducer'
,
'default'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'ap
ollo-config-service
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'ap
ollo-admin-service
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'ap
ollo-portal-service
'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'
fx-hermes-producer
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'ap
plication
'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'
application
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'ap
ollo-config-service
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'
fx-hermes-producer
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'ap
ollo-admin-service
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'ap
ollo-portal
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'
fx-hermes-producer
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'
application
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'ap
plication
'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'
application
'
);
INSERT
INTO
Item
(
GroupId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
GroupId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k2'
,
'v2'
,
'comment2'
);
INSERT
INTO
Item
(
GroupId
,
`Key`
,
Value
,
Comment
)
VALUES
(
2
,
'k3'
,
'v3'
,
'comment3'
);
INSERT
INTO
Item
(
GroupId
,
`Key`
,
Value
,
Comment
)
VALUES
(
5
,
'k3'
,
'v4'
,
'comment4'
);
INSERT
INTO
`RELEASE`
(
Name
,
Comment
,
AppId
,
ClusterName
,
GroupName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'apollo-config-service
'
,
'{"k1":"v1"}'
);
INSERT
INTO
`RELEASE`
(
Name
,
Comment
,
AppId
,
ClusterName
,
NamespaceName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'application
'
,
'{"k1":"v1"}'
);
apollo-configservice/pom.xml
View file @
0d9d990c
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-configservice
</artifactId>
<name>
Apollo ConfigService
</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<!-- end of apollo -->
<!-- redis -->
<!-- <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId>
</dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId>
</dependency> -->
<!-- end of redis -->
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
<exclusions>
<exclusion>
<artifactId>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-configservice
</artifactId>
<name>
Apollo ConfigService
</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<!-- end of apollo -->
<!-- redis -->
<!-- <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId>
</dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId>
</dependency> -->
<!-- end of redis -->
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
<exclusions>
<exclusion>
<artifactId>
spring-cloud-starter-archaius
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
ribbon-eureka
</artifactId>
<groupId>
com.netflix.ribbon
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-core
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-ec2
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-autoscaling
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-sts
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-route53
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<executable>
true
</executable>
</configuration>
</plugin>
</plugins>
</build>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
ribbon-eureka
</artifactId>
<groupId>
com.netflix.ribbon
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-core
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-ec2
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-autoscaling
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-sts
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
<exclusion>
<artifactId>
aws-java-sdk-route53
</artifactId>
<groupId>
com.amazonaws
</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<executable>
true
</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>
apollo-configservice/src/main/java/com/ctrip/apollo/configservice/controller/WebMvcConfig.java
0 → 100644
View file @
0d9d990c
package
com
.
ctrip
.
apollo
.
configservice
.
controller
;
import
java.util.List
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
@EnableWebMvc
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
PageableHandlerMethodArgumentResolver
resolver
=
new
PageableHandlerMethodArgumentResolver
();
resolver
.
setFallbackPageable
(
new
PageRequest
(
0
,
10
));
argumentResolvers
.
add
(
resolver
);
}
@Override
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
configurer
.
ignoreAcceptHeader
(
true
).
defaultContentType
(
MediaType
.
APPLICATION_JSON
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment