• Spring Boot 之 Hello World 战记


    1. Maven创建SpringBoot项目

    2. application.properties

    spring.session.store-type=none // 解决默认的30+编译错误

    3. demoNative.iml (屏蔽Mongo依赖)

        <!--
        <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:1.5.6.RELEASE" level="project" />
        <orderEntry type="library" name="Maven: org.mongodb:mongodb-driver:3.4.2" level="project" />
        <orderEntry type="library" name="Maven: org.mongodb:bson:3.4.2" level="project" />
        <orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.4.2" level="project" />
        <orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:1.10.6.RELEASE" level="project" />
        -->
    

    4. pom.xml (屏蔽Mongo依赖)

    		<!--
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-data-mongodb</artifactId>
    		</dependency>
    		-->

    5. DemoApplication.java

    @SpringBootApplication(exclude = {MongoAutoConfiguration.class, SecurityAutoConfiguration.class}) // 屏蔽默认Mongo设置(解决Socket链接错误) 屏蔽Tomcat用户认证(解决提示输入用户名密码)
    @RestController // 使之能够路由适配
    public class DemoApplication {
    
    	@RequestMapping("/") // 默认路由为"Hello World!"
    	public String hello(){
    		return "Hello World!";
    	}
    
    	public static void main(String[] args) {
    		SpringApplication.run(DemoApplication.class, args);
    	}
    }
    

      

    http://localhost:8080 默认显示 Hello World!

  • 相关阅读:
    nginx 配置以及常用命令
    django TypeError: 'module' object is not callable
    Django Meta内部类选项
    安装MySQL后要做的事
    MySQL存储引擎
    kali linux 2018.2 mysql密码修改后无效,外部无法连接问题。
    Django中CSS加载background url('')问题
    升级OPENSSH 和 OPENSSL
    Git创建仓库的方法(github翻译)
    Git标签(版本)管理
  • 原文地址:https://www.cnblogs.com/itfantasy/p/7307742.html
Copyright © 2020-2023  润新知