Tag: angular度2服务

在Docker上运行angular2 springboot应用程序,它显示索引页面,但没有加载angular度

我无法在docker上运行springboot angular2前端。 Angular2没有加载与docker战争容器,不明白为什么 <build> <finalName>${project.artifactId}</finalName> <defaultGoal>spring-boot:run</defaultGoal> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.2.7.RELEASE</version> <configuration> <addResources>src/main/webapp</addResources> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.5.0</version> <executions> <execution> <id>install angular2-contextmenu</id> <configuration> <executable>npm</executable> <arguments> <argument>install</argument> </arguments> </configuration> <phase>generate-resources</phase> <goals> <goal>exec</goal> </goals> </execution> <execution> <id>install npm</id> <configuration> <executable>npm</executable> <arguments> <argument>install</argument> </arguments> </configuration> <phase>generate-resources</phase> <goals> <goal>exec</goal> </goals> </execution> <execution> <id>build js</id> <configuration> <executable>npm</executable> <arguments> <argument>run</argument> […]

从angular2应用程序中调用docker容器中运行的服务

我有一个在Angular2中开发的UI应用程序。 我也有一些在Spring Boot中开发的服务。 我正在尝试从Angular应用程序调用Spring Boot服务。 以下是我的docker-compose.yml version: '2' networks: mynet: services: ui: image: uiimg networks: – mynet ports: – "4200:4200" srvc: image: scservice networks: – mynet ports: – "8080:8080" testsrvc: image: testsrvc networks: – mynet ports: – "8081:8081" 这就是我如何从angular度调用“srvc”定义的服务。 return this.http.get("http://srvc:8080/test").map(result => result.json()); 但是我得到错误srvc:8080 /testing失败加载资源:net :: ERR_NAME_NOT_RESOLVED 但是,我可以从“testsrvc”中的另一个服务调用http:// srvc:8080 / test ,没有任何问题。 我的理解是,由于UI请求源自浏览器,因此无法知道“srvc”是什么,而由于“testsrvc”也在容器中运行,所以它可以链接到“srvc” 那么我应该如何从angular度调用“srvc”呢? PS:我试过http:// […]