检查实验 spring cloud nacos nacos-server-2.3.0

1.概要

1.1 目标

就是做一个简单服务发现

1.2 要点

1.2.1 引入spring cloud 和spring alibaba的坐标


		
			
				org.springframework.cloud
				spring-cloud-dependencies
				${spring-cloud.version}
				pom
				import
			
			
				com.alibaba.cloud
				spring-cloud-alibaba-dependencies
				2022.0.0.0-RC2
				pom
				import
			
		
	

 1.2.2 导入web 和服务发现的坐标,配置管理的可不导入,目前不关心


    
        org.springframework.boot
        spring-boot-starter-web
    
    
        com.alibaba.cloud
        spring-cloud-starter-alibaba-nacos-discovery
    
    
    
        com.alibaba.cloud
        spring-cloud-starter-alibaba-nacos-config
    

 1.2.3 配置服务名称,没服务名称无法管理服务

spring:
  application:
    name: server3
  cloud:
    nacos:
      config:
        import-check:
          enabled: false

1.2.4  启动spring boot

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class);
        System.out.println("Hello world!");
    }
}

1.3 技术关键词

  • spring-cloud-dependencies 依赖
  • spring-cloud-alibaba-dependencies 依赖
  • spring-boot-starter-web 依赖
  • spring-cloud-starter-alibaba-nacos-discovery 服务注册和发现
  • @SpringBootApplication 启动扫描配置
  • SpringApplication.run(Main.class); 启动

2.代码

2.1 父工程



	4.0.0
	
		org.springframework.boot
		spring-boot-starter-parent
		3.2.2
		 
	
	com.xjc.springcloundtest
	demo21
	0.0.1-SNAPSHOT
	pom
	demo21
	demo21
	
		untitled
	
	
		21
		2023.0.0
	
	
		
			org.springframework.cloud
			spring-cloud-starter
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		
	
	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				${spring-cloud.version}
				pom
				import
			
			
				com.alibaba.cloud
				spring-cloud-alibaba-dependencies
				2022.0.0.0-RC2
				pom
				import
			
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	


2.2  服务工程

2.2.1 工程文件



    4.0.0
    
        com.xjc.springcloundtest
        demo21
        0.0.1-SNAPSHOT
    

    untitled

    
        21
        21
        UTF-8
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            com.alibaba.cloud
            spring-cloud-starter-alibaba-nacos-discovery
        
        
        
            com.alibaba.cloud
            spring-cloud-starter-alibaba-nacos-config
        
    

2.2.2 配置文件

 

spring:
  application:
    name: server3
  cloud:
    nacos:
      config:
        import-check:
          enabled: false

2.2.3 主函数

 

package com.xjc.springcloundtest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class);
        System.out.println("Hello world!");
    }
}

3.运行结果 

3.1 服务发现

检查实验 spring cloud nacos nacos-server-2.3.0_第1张图片

3.2 运行结果

 

Microsoft Windows [版本 10.0.19045.3324]
(c) Microsoft Corporation。保留所有权利。

D:\project\nacos3\nacos\bin>startup.cmd -m standalone
"nacos is starting with standalone"

         ,--.
       ,--.'|
   ,--,:  : |                                           Nacos 2.3.0
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 41276
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.0.107:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'

2024-02-02 09:16:37,935 INFO Tomcat initialized with port(s): 8848 (http)

2024-02-02 09:16:38,362 INFO Root WebApplicationContext: initialization completed in 3839 ms

2024-02-02 09:16:44,369 INFO Adding welcome page: class path resource [static/index.html]

2024-02-02 09:16:44,965 WARN You are asking Spring Security to ignore Ant [pattern='/**']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.

2024-02-02 09:16:44,967 INFO Will not secure Ant [pattern='/**']

2024-02-02 09:16:45,000 INFO Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4cc547a, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@7555b920, org.springframework.security.web.context.SecurityContextPersistenceFilter@67ef029, org.springframework.security.web.header.HeaderWriterFilter@9f46d94, org.springframework.security.web.csrf.CsrfFilter@5db99216, org.springframework.security.web.authentication.logout.LogoutFilter@578524c3, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6e57e95e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@56db847e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4152d38d, org.springframework.security.web.session.SessionManagementFilter@2e77b8cf, org.springframework.security.web.access.ExceptionTranslationFilter@5c1bd44c]

2024-02-02 09:16:45,047 INFO Exposing 1 endpoint(s) beneath base path '/actuator'

2024-02-02 09:16:45,105 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'

2024-02-02 09:16:45,148 INFO Nacos started successfully in stand alone mode. use embedded storage

2024-02-02 09:17:10,898 INFO Initializing Servlet 'dispatcherServlet'

2024-02-02 09:17:10,900 INFO Completed initialization in 1 ms

你可能感兴趣的:(spring,cloud,spring,cloud,java,spring,nacos)