The simplest service configuration of SpringBoot

Feel free to build a maven project

For example: project name t2

Write the dependent jar under maven's pom.xml

<!-- 继承父包 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.3.RELEASE</version>
</parent>
<!-- spring-boot的web启动的jar包 -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- 链接数据库 -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></    
        
        
    dependency>
    <!-- mybatis注解 -->
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.1.1</version>
    </dependency>
    <!--mysql驱动 -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
</dependencies>

Wait for the download to complete

Learn about the annotation usage of springBoot

1、@EnableAutoConfiguration

Used to start the program

E.g:

@RestController
@EnableAutoConfiguration
public class App {
 
 
@RequestMapping("/indexList")
public List<String> indexList() {
    List<String> list=new LinkedList<String>();
    list.add("1");
    list.add("2");
    list.add("3");
    return list;
}

public static void main(String[] args) {
    SpringApplication.run(App.class, args);
}
}

set up

application.properties

Insert control tomcat interface

server.port=80


After run starts, you can pass

localhost/t2/indexList

Return the json list collection

complete



Guess you like

Origin blog.csdn.net/feng8403000/article/details/80881574