标签:apach java image ack static 目的 cat 文件 color
1、File—>New—Maven Project,选择Create a simple project,点击next
2、输入Group Id,Artifact Id,Packaging选择pom,点击Finish
3、父工程创建完成后,修改父pom文件,加入SpringCloud依赖,spring boot maven插件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.lancode.iot</groupId> <artifactId>mqtt_alan</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <!-- spring-cloud所有项目依赖包 --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <finalName>mqtt-alan-root</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <encoding>utf-8</encoding> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
4、开始创建子项目eureka,右键工程 New—>Maven Module,选择Create a simple project,输入Module Name,点击Next
5、输入Group Id,Packaging选择jar,点击Finish完成子项目创建
6、eureka子项目创建完成后,修改pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.lancode.iot</groupId> <artifactId>mqtt_alan</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>lan-eureka</artifactId> <!-- 添加注册中心依赖的包文件 --> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> <!-- 必须引入gson 2.6版的替换2.2版的,不然会报错不兼容 --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.6</version> <!--<scope>compile</scope>--> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
7、在eureka项目的src/main/java/包根目录下创建启动类如下
@EnableEurekaServer @SpringBootApplication public class EurekaApplication { public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); } }
8、在eureka项目的src/main/resources根目录下创建application.yml配置文件
#本机端口
server:
port: 8761
eureka:
client:
#是否向注册中心注册自己
register-with-eureka: false
#是否从注册中心查询服务
fetch-registry: false
#注册中心地址
service-url:
defaultZone: http://localhost:8761/eureka/
9、eclipse创建springcloud项目并集成eureka完成
eclipse创建springcloud项目(一)——创建项目父工程、Eureka
标签:apach java image ack static 目的 cat 文件 color
原文地址:https://www.cnblogs.com/alan6/p/11517970.html