参考网站

Angular 中文官网:https://angular.cn/

参考代码:https://ng.ant.design/#/components/dropdown 

npm install -g @angular/cli  ->  npm install -> ng build -> 普通angular工程:ng server  

npm install -g @angular/cli  ->  npm install -> ng build -> 增加跨域配置工程启动: npm start 

一、安装软件

1、安装nodejs 和 angularjs/cli

https://nodejs.org/en/

        安装 nodejs

安装 angularjs/cli:   npm  install  -g   @angular/cli

执行 npm install

执行 ng build,编译前台代码输出到 spring boot 资源目录

2、安装augury

在google网上应用商店添加插件augury ,用来调试前端代码

3、新建普通的 angular 项目 - ng new hello

通过命令 ng new hello 生成一个新项目以及应用的骨架代码

通过命令 ng server 启动项目,默认端口4200。

二、Spring boot 和 angular 集成

Spring boot 需要修改的地方在angular-cli.json中:

1、在springboot项目中新建/复制 angular 项目

方法一: 在src 目录下通过命令添加angular项目 : ng new angular

方法二: 将之前创建好的项目copy进来

设置angular项目的输出目录为springboot的资源目录

修改angular-cli.json 配置文件的name 和 outDir

该项目下name为 iot_hub

outDir 为../resources/static(静态资源路径,系统可以直接访问且路径下的所有文件均可被直接读取)

编译angular项目,产生输出到springboot资源目录

npm  install

ng  server --proxy-conf proxy.conf

  ng build

2、启动工程

1、启动Spring boot

2、启动前端angular工程调试:npm  start

3、访问服务

http://localhost:8080

http://localhost:4200

三、附录 - 常见问题

1、解决跨域问题

加一个这样的文件

同时修改package.json中的start

2、热部署调试工程

buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
maven {
url "http://repo.iop.inspur.com:8081/nexus/content/groups/public"
}
}

dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.inspur.iot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
maven {
url "http://repo.iop.inspur.com:8081/nexus/content/groups/public"
}
}
bootRun {
addResources = true
}

configurations.all {
exclude module: 'google-collections' 
}

dependencies {

compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')

compile('io.springfox:springfox-swagger2:2.6.1')
compile('io.springfox:springfox-swagger-ui:2.6.1')

compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('mysql:mysql-connector-java:5.1.21')

compile('org.springframework.boot:spring-boot-starter-data-redis')
// compile("org.springframework:spring-orm")

compile("org.springframework.boot:spring-boot-devtools")
compile ("org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE")

testCompile('org.springframework.boot:spring-boot-starter-test')
}

iot前台开发环境:搭建 SpringBoot+angularJs2的更多相关文章

  1. iot前台开发环境:请求示例

    参考链接:http://www.cnblogs.com/keatkeat/category/872790.html 编辑->update保存 一.typescipt import { Injec ...

  2. iot前台开发环境:前后台访问映射

    一.前端映射- java代码 二.路由设置 -前台代码 三.访问应用

  3. Windows 10 IoT Serials 1 - 针对Minnow Board MAX的Windows 10 IoT开发环境搭建

    目前,微软针对Windows IoT计划支持的硬件包括树莓派2,Minnow Board MAX 和Galileo (Gen 1和Gen 2).其中,Galileo (Gen 1和Gen 2)运行的是 ...

  4. (转载)JAVA敏捷开发环境搭建

    整个软件项目分为四个环境 开发本地环境.开发环境.测试环境.IDC环境.和传统C++开发不一样的模式是多了第一个开发本地环境.这是为什么呢,因为目前大部分开发人员还是比较熟悉windows下开发.对于 ...

  5. Guns(开源后台管理系统框架)实战(一)——开发环境搭建

    1. 开发环境搭建 1.1. 开发环境要求 1.2. 配置Maven 1.3. 配置MySQL 1.4. Git克隆项目 1.5. Eclipse导入系统 2. 小结 3. 参考引用 1. 开发环境搭 ...

  6. 如何学习web开发环境搭建和脚手架

    Web前端的学习路线 第一阶段: HTML+CSS: HTML进阶.CSS进阶.div+css布局.HTML+css整站开发. JavaScript基础: Js基础教程.js内置对象常用方法.常见DO ...

  7. gradle ofbiz 16 开发环境搭建

    原 gradle ofbiz 16 开发环境搭建 2017年02月13日 10:59:19 阅读数:2702 1.安装jdk 2.配置jdk环境变量 3.eclipse 安装svn 插件 4.svn下 ...

  8. 手把手教你 Apache DolphinScheduler 本地开发环境搭建 | 中英文视频教程

    点击上方 蓝字关注我们 最近,一些小伙伴反馈对小海豚的本地开发环境搭建过程不太了解,这不就有活跃的贡献者送来新鲜的视频教程!在此感谢@Tianqi-Dotes 的细致讲解 贡献者还贴心地录制了中英文两 ...

  9. python开发环境搭建

    虽然网上有很多python开发环境搭建的文章,不过重复造轮子还是要的,记录一下过程,方便自己以后配置,也方便正在学习中的同事配置他们的环境. 1.准备好安装包 1)上python官网下载python运 ...

随机推荐

  1. java ---日期的格式化

    import java.util.Date; import java.util.Scanner; import java.text.SimpleDateFormat; import java.util ...

  2. scala开发环境安装

    安装JDK    java 运行环境 ,这里不详说了,熟悉java的朋友应该都会,我们主要关注下Scala的安装. 安装scala    1.下载scala    http://yunpan.cn/c ...

  3. asp.net core 发布centos 7 遇到的坑

    只是简单记录 .net core 在linux 的安装部署步骤,大神可以忽略 虚拟机:VMware Workstation Pro Linux 版本:http://mirrors.aliyun.com ...

  4. AJAX跨域问题解决方法(3)——被调用方解决跨域

    被调用方解决跨域是指在HTTP响应头中增加指定的字段,允许调用方调用 可以在两种地方增加1.apache/nginx(HTTP服务器)2.tomcat(应用服务器) 浏览器如何判断跨域?仔细观察可以发 ...

  5. 永久开启完整版Google Play

    中国内地使用Play商店只能看见两个项目,即应用和游戏,但实际上有六个,见图.解决方法,第一,通过fqrouter2进入Play商店,见图,第二,通过google wallet. 参考网址:http: ...

  6. python 全栈开发,Day4

    python之文件操作 一.文件操作基本流程 计算机系统分为:计算机硬件,操作系统,应用程序三部分. 我们用python或其他语言编写的应用程序若想要把数据永久保存下来,必须要保存于硬盘中,这就涉及到 ...

  7. 笔记:Maven 下载和安装

    Windows 安装 下载 Apache Maven,下载地址为 http://maven.apache.org/ 解压缩下载的 ZIP 文件,复制到安装目录 增加环境变量 M2_HOME ,值为 A ...

  8. 给定n,求1/x + 1/y = 1/n (x<=y)的解数~hdu-1299~(分解素因子详解)

    链接:https://www.nowcoder.com/acm/contest/90/F来源:牛客网 题目描述 给定n,求1/x + 1/y = 1/n (x<=y)的解数.(x.y.n均为正整 ...

  9. newInstance()和new()的区别

    转载:http://www.jobui.com/mianshiti/it/java/7148/ newInstance: 弱类型.低效率.只能调用无参构造.new: 强类型.相对高效.能调用任何pub ...

  10. KVM之十一:调整cpu和内存

    1.virsh edit snale (更改前要将snale shutdown) 找到"memory"和"vcpu"标签,将 <memory unit=' ...