初学springboot, 如何快速使用maven搭建springboot项目呢

时间:2017-06-18 18:47:38   收藏:0   阅读:3564

 

    搭建Springboot 推荐使用maven, 但也可以不使用maven,用正常的java工程。

  

  技术分享

  技术分享

  技术分享

  技术分享

  技术分享

<!-- 继承父包 -->
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
 </parent>
    <dependencies>
            <!-- spring-boot的web启动的jar包 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
            <!-- maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.5.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
<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>org.springboot</groupId>
    <artifactId>SpringBoot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    
    <!-- 继承父包 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>
    
    <dependencies>
            <!-- spring-boot的web启动的jar包 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
      
    <build>
        <plugins>
            <!-- 配置java版本 -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <!-- 配置war版本 -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <version>3.1</version>
                </configuration>
            </plugin>
            <!-- maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.5.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <repositories>  
        <repository>  
            <id>spring-snapshots</id>  
            <url>http://repo.spring.io/snapshot</url>  
            <snapshots><enabled>true</enabled></snapshots>  
        </repository>  
        <repository>  
            <id>spring-milestones</id>  
            <url>http://repo.spring.io/milestone</url>  
        </repository>  
    </repositories>  
    <pluginRepositories>  
        <pluginRepository>  
            <id>spring-snapshots</id>  
            <url>http://repo.spring.io/snapshot</url>  
        </pluginRepository>  
        <pluginRepository>  
            <id>spring-milestones</id>  
            <url>http://repo.spring.io/milestone</url>  
        </pluginRepository>  
    </pluginRepositories>  
</project>

 

  技术分享

  技术分享

  技术分享

  技术分享

  技术分享

  技术分享

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        SpringApplication.run(Demo.class, args);
    }

}
@RestController
@EnableAutoConfiguration
public class Demo {

    @RequestMapping("/")
    String helloWord() {
        return "helloWorld";
    }
}

技术分享

技术分享

 

原文:http://www.cnblogs.com/szsq/p/7040934.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!