六、运行后台代码

GitEgg...大约 1 分钟快速开始快速开始安装Java

1. SpringCloud 微服务涉及到多个 SpringBoot 项目的启动,单个启动比较繁琐,Idea 提供了 services 窗口,可以一键启动/停止所有微服务,如果 Idea 中没有出现这个窗口,可以查看工程下 .idea-> workspace.xml 文件是否有以下配置,如果没有则增加:

  <component name="RunDashboard">
    <option name="configurationTypes">
      <set>
        <option value="SpringBootApplicationConfigurationType" />
      </set>
    </option>
  </component>

2. 添加以上配置之后,直接右键执行其中一个微服务,或者在 Idea 中点击 View -> Tool Windows -> Services 都可以显示 services 窗口,这样就可以在窗口一键启动/停止所有微服务了。

3. 启动成功后,services 窗口可以显示服务名和服务端口,点击对应服务名,右侧可以显示其 Console 窗口。

常见问题:

如果 services 窗口未展示 SpringBoot 微服务,那么在 Services 窗口点击+ --> Run Configuration Type --> Spring Boot