一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 

一、创建maven项目,打包方式为jar包

二、引入依赖

<!-- 父级依赖 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
</parent>

<!-- springmvc和spring的jar包 -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<!-- maven项目指定编译器版本 -->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>    

二、创建配置文件application.properties

#服务运行端口号
server.port=8088
#服务运行路径
server.context-path=/www

三、创建入口文件MyApplication.java

//exclude={RedisAutoConfiguration.class}:关闭自动配置
@EnableAutoConfiguration(exclude = {RedisAutoConfiguration.class})//启用自动配置
@Controller
public class IndexController {

    @RequestMapping("/")
    @ResponseBody
    public String first() {
        return "Hello world!";
    }

    //入口
    public static void main(String[] args) {
        SpringApplication.run(IndexController.class, args);
    }
}

 备注:

  1、所有的默认配置都在【spring-boot-autoconfigure】包下

  2、排除配置【@EnableAutoConfiguration(exclude = {RedisAutoConfiguration.class})】

  3、指定banner:新建【banner.txt】文件,然后放在resources目录下

 

posted on 2020-03-11 21:40  一路繁花似锦绣前程  阅读(154)  评论(0编辑  收藏  举报