springBoot基礎使用(基於Maven)

pom.xml

<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>com.project.test</groupId>
	<artifactId>springboot</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<properties>
		<!--web.xml文件可以缺失 -->
		<failOnMissingWebXml>false</failOnMissingWebXml>
		<!--編碼格式 -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<!--jdk版本 -->
		<java.version>1.8</java.version>
	</properties>
	<!-- 父模塊、引入springboot的基本依賴文件,springboot的基本包都在父模塊中,列如tomcat插件、其他的jar -->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.10.RELEASE</version>
	</parent>
	<dependencies>
		<!-- 引入springboot的web模塊 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<!-- springboot jsp模塊解析 -->
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
			<scope>provided</scope>
		</dependency>
	</dependencies>
</project>

aciton文件配置:

package com.project.action;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * @author Administrator
 *
 */
@Controller
@SpringBootApplication
public class LoginAction {
	@RequestMapping("/login.action")
	public String login() {
		System.out.println("測試springBoot");
		return "index.jsp";
	}
	/**
	 * 運行springboot程序
	 * @param args
	 */
	public static void main(String[] args) {
		SpringApplication.run(LoginAction.class, args);
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章