加强廉政教育网站建设,深圳广告标识设计公司,珠海在线网站制作公司,西安紧急通知目录
1 Springboot的创建
步骤
2 项目的书写和运行 创建service包并在其下写一个service文件
项目的运行
pom文件的一些配置
parent
web
test
打包
打包过程 1 Springboot的创建
步骤
首先new一个新项目 然后依照如下创建 2 项目的书写和运行 创建service包并…目录
1 Springboot的创建
步骤
2 项目的书写和运行 创建service包并在其下写一个service文件
项目的运行
pom文件的一些配置
parent
web
test
打包
打包过程 1 Springboot的创建
步骤
首先new一个新项目 然后依照如下创建 2 项目的书写和运行 创建service包并在其下写一个service文件
注意service一定要放在项目名的包下 这里还有一些注解的解释请仔细观看
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//返回字符串类型
RestController
public class HelloController {//接口 http://localhost:8080/helloRequestMapping(/hello)public String hello(){return hello world;}
}
项目的运行
运行项目名包下的Appliaction文件即可
//本身就是spring的一个组件
SpringBootApplication
public class DemoSpringBootApplication {public static void main(String[] args) {SpringApplication.run(DemoSpringBootApplication.class, args);}}
pom文件的一些配置
parent
!--有一个父项目-- parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.7.14/versionrelativePath/ !-- lookup parent from repository --
/parent web !--web 依赖 配好了 Tomact servlet .xml-- dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId
/dependency test
!--单元测试-- dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope
/dependency 打包 !--打jar包程序--pluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins
/build 打包后会形成一个jar文件,这个jar文件也相当于一个接口。通过在命令窗口执行这个文件也可以达到效果。
打包过程
1 23在cmd窗口执行文件