Commit 4054304f authored by Yiming Liu's avatar Yiming Liu

Inject authed RestTemplate into Portal

parent 429792a4
...@@ -26,10 +26,5 @@ ...@@ -26,10 +26,5 @@
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -67,6 +67,11 @@ ...@@ -67,6 +67,11 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- end of eureka --> <!-- end of eureka -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package com.ctrip.apollo.portal; package com.ctrip.apollo;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter; import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
......
package com.ctrip.apollo.portal.api; package com.ctrip.apollo.portal.api;
import com.ctrip.apollo.core.enums.Env; import javax.annotation.PostConstruct;
import com.ctrip.apollo.core.exception.ServiceException;
import com.ctrip.apollo.portal.service.ServiceLocator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.ctrip.apollo.common.auth.RestTemplateFactory;
import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.core.exception.ServiceException;
import com.ctrip.apollo.portal.service.ServiceLocator;
public class API { public class API {
@Autowired @Autowired
protected ServiceLocator serviceLocator; protected ServiceLocator serviceLocator;
@Autowired @Autowired
private RestTemplateFactory restTemplateFactory;
protected RestTemplate restTemplate; protected RestTemplate restTemplate;
@PostConstruct
private void postConstruct() {
restTemplate = restTemplateFactory.getObject();
}
public String getAdminServiceHost(Env env) { public String getAdminServiceHost(Env env) {
// 本地测试用 // 本地测试用
// return "http://localhost:8090"; // return "http://localhost:8090";
...@@ -25,5 +35,5 @@ public class API { ...@@ -25,5 +35,5 @@ public class API {
} }
return ""; return "";
} }
} }
...@@ -15,4 +15,4 @@ ctrip: ...@@ -15,4 +15,4 @@ ctrip:
apollo: apollo:
portal: portal:
env: dev env: local
...@@ -4,6 +4,8 @@ import org.junit.runner.RunWith; ...@@ -4,6 +4,8 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.ctrip.apollo.PortalApplication;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PortalApplication.class) @SpringApplicationConfiguration(classes = PortalApplication.class)
public abstract class AbstractPortalTest { public abstract class AbstractPortalTest {
......
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