You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ma...@apache.org on 2019/08/07 10:41:44 UTC

[servicecomb-samples] 03/37: separate api in different project

This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 1370b2fd36b962b036be350bc208a23eb1490ab9
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 15:14:10 2019 +0800

    separate api in different project
---
 .../{common => api/file-service/endpoint}/pom.xml  | 11 ++++++--
 .../samples/porter/file/api/FileEndpoint.java      |  3 ++-
 .../{common => api/file-service}/pom.xml           | 13 +++++++---
 .../{common => api/file-service/service}/pom.xml   |  4 +--
 .../samples/porter/file/api/FileService.java       |  2 +-
 porter_lightweight/{common => api}/pom.xml         | 11 +++++---
 .../{common => api/user-service/endpoint}/pom.xml  | 11 ++++++--
 .../samples/porter/user/api/UserEndpoint.java      |  4 ++-
 .../{common => api/user-service}/pom.xml           | 13 +++++++---
 .../{common => api/user-service/service}/pom.xml   |  4 +--
 .../samples/porter/user/api/SessionInfo.java       |  2 +-
 .../samples/porter/user/api/UserService.java       |  2 +-
 .../common/src/main/resources/microservice.yaml    | 30 ----------------------
 porter_lightweight/file-service/pom.xml            |  2 +-
 .../porter/file/service/FileServiceImpl.java       |  2 +-
 .../main/resources/META-INF/spring/file.bean.xml   |  2 --
 .../src/main/resources/microservice.yaml           |  9 +++++++
 porter_lightweight/gateway-service/pom.xml         |  2 +-
 .../samples/porter/gateway/AuthHandler.java        | 13 +++++-----
 .../src/main/resources/microservice.yaml           |  8 ++++++
 porter_lightweight/pom.xml                         |  2 +-
 porter_lightweight/user-service/pom.xml            |  2 +-
 .../samples/porter/user/dao/SessionInfoModel.java  |  2 +-
 .../samples/porter/user/dao/SessionMapper.java     |  2 +-
 .../porter/user/service/UserServiceImpl.java       |  5 ++--
 .../main/resources/META-INF/spring/user.bean.xml   |  3 ---
 .../src/main/resources/microservice.yaml           |  8 ++++++
 27 files changed, 96 insertions(+), 76 deletions(-)

diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/endpoint/pom.xml
similarity index 78%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/endpoint/pom.xml
index 772ec4e..f9ae57e 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/endpoint/pom.xml
@@ -21,11 +21,18 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>file-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>file-service-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>file-service-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
rename to porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
index e7c1f0c..8ff7dac 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
+++ b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
@@ -15,9 +15,10 @@
  * limitations under the License.
  */
 
-package samples.porter.file.api;
+package org.apache.servicecomb.samples.porter.file.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.file.api.FileService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.DeleteMapping;
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/pom.xml
similarity index 85%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/pom.xml
index 772ec4e..be4d84a 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/pom.xml
@@ -15,17 +15,22 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
+
 <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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>porter-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>file-service-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/service/pom.xml
similarity index 92%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/service/pom.xml
index 772ec4e..a0a5dc9 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/service/pom.xml
@@ -21,11 +21,11 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>file-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>file-service-api-service</artifactId>
   <packaging>jar</packaging>
 
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
rename to porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
index 606e727..ff7777a 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
+++ b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.file.api;
+package org.apache.servicecomb.samples.porter.file.api;
 
 import org.springframework.web.multipart.MultipartFile;
 
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/pom.xml
similarity index 88%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/pom.xml
index 772ec4e..018a879 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/pom.xml
@@ -15,6 +15,7 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
+
 <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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
@@ -25,7 +26,11 @@
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>porter-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>file-service</module>
+    <module>user-service</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/endpoint/pom.xml
similarity index 78%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/user-service/endpoint/pom.xml
index 772ec4e..5c96d3a 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/endpoint/pom.xml
@@ -21,11 +21,18 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>user-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>user-service-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>user-service-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java b/porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
similarity index 91%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
rename to porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
index 8a248d3..40df5bb 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
+++ b/porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
@@ -15,9 +15,11 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/pom.xml
similarity index 85%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/user-service/pom.xml
index 772ec4e..31e433d 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/pom.xml
@@ -15,17 +15,22 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
+
 <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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>porter-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>user-service-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/service/pom.xml
similarity index 92%
rename from porter_lightweight/common/pom.xml
rename to porter_lightweight/api/user-service/service/pom.xml
index 772ec4e..083b309 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/service/pom.xml
@@ -21,11 +21,11 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>user-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>user-service-api-service</artifactId>
   <packaging>jar</packaging>
 
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
similarity index 96%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java
rename to porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
index 2aca62b..6358104 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java
+++ b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 public class SessionInfo {
   private String sessiondId;
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
rename to porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
index a37ffa3..aa882f9 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
+++ b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 public interface UserService {
   public SessionInfo login(String userName,
diff --git a/porter_lightweight/common/src/main/resources/microservice.yaml b/porter_lightweight/common/src/main/resources/microservice.yaml
deleted file mode 100644
index 9e3de6e..0000000
--- a/porter_lightweight/common/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements.  See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License.  You may obtain a copy of the License at
-##
-##      http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-servicecomb-config-order: 10
-
-APPLICATION_ID: porter-application
-service_description:
-  version: 0.0.1
-
-servicecomb:
-  service:
-    registry:
-      address: http://localhost:30100
-      instance:
-        watch: false
\ No newline at end of file
diff --git a/porter_lightweight/file-service/pom.xml b/porter_lightweight/file-service/pom.xml
index d42ed5c..6ae53d6 100644
--- a/porter_lightweight/file-service/pom.xml
+++ b/porter_lightweight/file-service/pom.xml
@@ -31,7 +31,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>file-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
   </dependencies>
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
index 78aea60..5053aee 100644
--- a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
@@ -25,7 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 @Service
-public class FileServiceImpl implements samples.porter.file.api.FileService {
+public class FileServiceImpl implements org.apache.servicecomb.samples.porter.file.api.FileService {
     @Autowired
     private FileStoreService fileService;
 
diff --git a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
index 4a3846c..c679960 100644
--- a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
+++ b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
@@ -24,6 +24,4 @@
         http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-    <!-- Only scan file components. Other beans in common module like org.apache.servicecomb.samples.porter.user.api.UserEndpoint ignored. -->
-    <context:component-scan base-package="samples.porter.file" />
 </beans>
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/resources/microservice.yaml b/porter_lightweight/file-service/src/main/resources/microservice.yaml
index bb71959..44654c4 100644
--- a/porter_lightweight/file-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/file-service/src/main/resources/microservice.yaml
@@ -19,10 +19,19 @@
 # override common configurations in common module
 servicecomb-config-order: 10
 
+APPLICATION_ID: porter-application
+
 service_description:
+  version: 0.0.1
   name: file-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30120
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9091
 
diff --git a/porter_lightweight/gateway-service/pom.xml b/porter_lightweight/gateway-service/pom.xml
index 427c75e..c0188fa 100644
--- a/porter_lightweight/gateway-service/pom.xml
+++ b/porter_lightweight/gateway-service/pom.xml
@@ -35,7 +35,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>user-service-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
index 73cc06d..13a7e9a 100644
--- a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
@@ -23,6 +23,7 @@ import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.utils.JsonUtils;
 import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -33,13 +34,11 @@ import org.springframework.util.concurrent.ListenableFutureCallback;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 
-import samples.porter.user.api.SessionInfo;
-
 
 public class AuthHandler implements Handler {
   private CseAsyncRestTemplate restTemplate = new CseAsyncRestTemplate();
 
-  //服务端会话过期是10分钟,客户端缓存1分钟会话。
+  // session expires in 10 minutes, cache for 1 seconds to get rid of concurrent scenarios.
   private Cache<String, String> sessionCache = CacheBuilder.newBuilder()
       .expireAfterAccess(30, TimeUnit.SECONDS)
       .build();
@@ -49,7 +48,7 @@ public class AuthHandler implements Handler {
     if (invocation.getMicroserviceName().equals("user-service")
         && (invocation.getOperationName().equals("login")
             || (invocation.getOperationName().equals("getSession")))) {
-      // login: 直接返回认证结果。  开发者需要在JS里面设置cookie。 
+      // login:return session id, set cookie by javascript
       invocation.next(asyncResponse);
     } else {
       // check session
@@ -61,7 +60,7 @@ public class AuthHandler implements Handler {
       String sessionInfo = sessionCache.getIfPresent(sessionId);
       if (sessionInfo != null) {
         try {
-          // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+          // session info stored in InvocationContext. Microservices can get it. 
           invocation.addContext("session-id", sessionId);
           invocation.addContext("session-info", sessionInfo);
           invocation.next(asyncResponse);
@@ -71,7 +70,7 @@ public class AuthHandler implements Handler {
         return;
       }
 
-      // 在网关执行的Hanlder逻辑,是reactive模式的,不能使用阻塞调用。
+      // In edge, handler is executed in reactively. Must have no blocking logic.
       ListenableFuture<ResponseEntity<SessionInfo>> sessionInfoFuture =
           restTemplate.getForEntity("cse://user-service/v1/user/session?sessionId=" + sessionId, SessionInfo.class);
       sessionInfoFuture.addCallback(
@@ -89,7 +88,7 @@ public class AuthHandler implements Handler {
                 return;
               }
               try {
-                // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+                // session info stored in InvocationContext. Microservices can get it. 
                 invocation.addContext("session-id", sessionId);
                 String sessionInfoStr = JsonUtils.writeValueAsString(sessionInfo);
                 invocation.addContext("session-info", sessionInfoStr);
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
index 5623c60..a3edac1 100644
--- a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -19,10 +19,18 @@
 # override common configurations in common module
 servicecomb-config-order: 100
 
+APPLICATION_ID: porter-application
 service_description:
+  version: 0.0.1
   name: gateway-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9090?sslEnabled=false
 
diff --git a/porter_lightweight/pom.xml b/porter_lightweight/pom.xml
index 5a7e539..f891518 100644
--- a/porter_lightweight/pom.xml
+++ b/porter_lightweight/pom.xml
@@ -65,7 +65,7 @@
   </dependencies>
 
   <modules>
-    <module>common</module>
+    <module>api</module>
     <module>file-service</module>
     <module>user-service</module>
     <module>gateway-service</module>
diff --git a/porter_lightweight/user-service/pom.xml b/porter_lightweight/user-service/pom.xml
index 04c50ae..7e8c20f 100644
--- a/porter_lightweight/user-service/pom.xml
+++ b/porter_lightweight/user-service/pom.xml
@@ -36,7 +36,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>user-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
index f363af5..fa60d33 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.samples.porter.user.dao;
 
-import samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 
 public class SessionInfoModel {
   private int id;
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
index fb3306b..e09df8e 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.samples.porter.user.dao;
 
-import samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 
 public interface SessionMapper {
     void createSession(SessionInfo sessionInfo);
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
index 2633d57..2d49b46 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
@@ -24,6 +24,8 @@ import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.UserService;
 import org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel;
 import org.apache.servicecomb.samples.porter.user.dao.SessionMapper;
 import org.apache.servicecomb.samples.porter.user.dao.UserInfo;
@@ -36,9 +38,6 @@ import org.springframework.stereotype.Service;
 
 import com.netflix.config.DynamicPropertyFactory;
 
-import samples.porter.user.api.SessionInfo;
-import samples.porter.user.api.UserService;
-
 @Service
 public class UserServiceImpl implements UserService {
   private static Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
diff --git a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
index e1cdd94..3cc2dd2 100644
--- a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
+++ b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
@@ -26,9 +26,6 @@
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-    <context:component-scan base-package="samples.porter.user" >
-    </context:component-scan>
-
     <bean id="dataSource"
         class="org.apache.commons.dbcp2.BasicDataSource"
         destroy-method="close">
diff --git a/porter_lightweight/user-service/src/main/resources/microservice.yaml b/porter_lightweight/user-service/src/main/resources/microservice.yaml
index 81ef89e..9c25055 100644
--- a/porter_lightweight/user-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/user-service/src/main/resources/microservice.yaml
@@ -19,9 +19,17 @@
 # override common configurations in common module
 servicecomb-config-order: 10
 
+APPLICATION_ID: porter-application
 service_description:
+  version: 0.0.1
   name: user-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30120
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9093
\ No newline at end of file