Commit fc4c9918befb2fe4c2077f6a4cc87f50ebd22807
1 parent
faab39dd
Exists in
master
增加服务注册功能
Showing
4 changed files
with
35 additions
and
11 deletions
Show diff stats
springboot/pom.xml
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | |
18 | 18 | <properties> |
19 | 19 | <java.version>1.8</java.version> |
20 | + <spring-cloud.version>Greenwich.SR1</spring-cloud.version> | |
20 | 21 | </properties> |
21 | 22 | |
22 | 23 | <dependencies> |
... | ... | @@ -124,8 +125,25 @@ |
124 | 125 | <artifactId>commons-lang3</artifactId> |
125 | 126 | <version>3.1</version> |
126 | 127 | </dependency> |
128 | + <!--注册中心--> | |
129 | + <dependency> | |
130 | + <groupId>org.springframework.cloud</groupId> | |
131 | + <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> | |
132 | + </dependency> | |
127 | 133 | </dependencies> |
128 | 134 | |
135 | + <dependencyManagement> | |
136 | + <dependencies> | |
137 | + <dependency> | |
138 | + <groupId>org.springframework.cloud</groupId> | |
139 | + <artifactId>spring-cloud-dependencies</artifactId> | |
140 | + <version>${spring-cloud.version}</version> | |
141 | + <type>pom</type> | |
142 | + <scope>import</scope> | |
143 | + </dependency> | |
144 | + </dependencies> | |
145 | + </dependencyManagement> | |
146 | + | |
129 | 147 | <build> |
130 | 148 | <finalName>springboot-sincere</finalName> |
131 | 149 | <plugins> | ... | ... |
springboot/src/main/java/com/sincre/springboot/ApiModel/UserInfo.java
springboot/src/main/java/com/sincre/springboot/SpringbootApplication.java
... | ... | @@ -7,6 +7,7 @@ import org.springframework.boot.SpringApplication; |
7 | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
8 | 8 | import org.springframework.boot.builder.SpringApplicationBuilder; |
9 | 9 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
10 | +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | |
10 | 11 | |
11 | 12 | import javax.swing.*; |
12 | 13 | import java.awt.*; |
... | ... | @@ -15,12 +16,13 @@ import java.util.Date; |
15 | 16 | |
16 | 17 | @MapperScan("com.sincre.springboot.mapper") |
17 | 18 | @SpringBootApplication |
19 | +@EnableDiscoveryClient | |
18 | 20 | public class SpringbootApplication extends SpringBootServletInitializer { |
19 | 21 | |
20 | 22 | public static void main(String[] args) { |
21 | 23 | |
22 | 24 | SpringApplication.run(SpringbootApplication.class, args); |
23 | - new YinShiController().GetYinShiToken();//获取萤石云token | |
25 | + //new YinShiController().GetYinShiToken();//获取萤石云token | |
24 | 26 | } |
25 | 27 | |
26 | 28 | } | ... | ... |
springboot/src/main/resources/application.properties
1 | -server.port=1111 | |
2 | -# 设置数据库相关属性 | |
3 | -spring.datasource.username=thd | |
4 | -spring.datasource.password=pmd19930415A | |
5 | -spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;database=test | |
6 | -spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver | |
7 | -mybatis.config-location=classpath:mybatis-config.xml | |
8 | -mybatis.mapper-locations=classpath:/mapper/*.xml | |
9 | -mybatis.type-aliases-package=com.sincre.springboot.model | |
10 | 1 | \ No newline at end of file |
2 | +spring.application.name=iot-api | |
3 | +#server.port=8088 | |
4 | +# 设置数据库相关属性 | |
5 | +spring.datasource.username=thd | |
6 | +spring.datasource.password=pmd19930415A | |
7 | +spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;database=test | |
8 | +spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver | |
9 | +mybatis.config-location=classpath:mybatis-config.xml | |
10 | +mybatis.mapper-locations=classpath:/mapper/*.xml | |
11 | +mybatis.type-aliases-package=com.sincre.springboot.model | |
12 | + | |
13 | +#对应服务注册中心的配置内容,指定服务注册中心的位置。 | |
14 | +eureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/ | |
11 | 15 | \ No newline at end of file | ... | ... |