Commit 4054304f by Yiming Liu

Inject authed RestTemplate into Portal

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