一.在myeclipse中配置sts插件,配好环境 ,
在maven的目录下找到settings.xml文件.找到<profiles/>标签,
在该标签内添加以下代码:
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDeafult>true</activeByDeafult>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
创建maven jar的工程
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.yuming</groupId>
<artifactId>springboot-shiro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- 导入springboot相关依赖 -->
<!-- 导入父项目 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<!-- -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 必须添加该依赖,不添加该依赖,就报错,且springboot项目启动失败 -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<!-- <scope>test</scope> -->
</dependency>
</dependencies>
<!-- 部署的时候,需要该插件
该插件的作用:可将项目打包成一个可执行的jar包
-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application:
package com.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @springbootApplication 标注是一个主程序类,说明这是一个springboot项目
* @author
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
//作用:启动springboot应用
SpringApplication.run(Application.class, args);
}
}
TestController:
package com.test.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class TestController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "Hello World!!!";
}
}
后台启动:
浏览器测试: