标签:本地 config arraylist src autowire group sem ora 错误
优点:
创建SpringBoot项目的几种方式:
访问http://start.spring.io/ 进入Spring项目Initializr
生成下载demo.zip
导入项目
1.Import一个Maven项目
2.选择要导入的文件
3.项目骨架
l 直接run启动程序里的Main()方法
l 安装过STS插件或使用STS可以在项目上右键RunAS->Spring Boot APP
运行成功提示信息:
如果运行报错,请参照常见问题。
在resources目录下新建banner.txt
http://www.network-science.de/ascii/ 英文
https://www.degraeve.com/img2txt.php 图片
${AnsiColor.BRIGHT_CYAN} _ _ _ _ _ ______ | | (_)| | | | | | | ___ \ | | _ | |_ | |_ | | ___ | |_/ /__ _ __ _ ___ | | | || __|| __|| | / _ \| __// _` | / _` | / _ \ | |____| || |_ | |_ | || __/| | | (_| || (_| || __/ \_____/|_| \__| \__||_| \___|\_| \__,_| \__, | \___| __/ | |___/ ${AnsiColor.BRIGHT_RED} Logo Designer: LittlePage Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
菜单栏中
Help -> EclipseMarketplace
搜索Theme
傻瓜式安装这个,安装完成会提示重启,跟随指引选择喜欢的风格。
把所有的配置全放在这个文件里,方便统一管理,maven也可以做到
server.port=90
server.servlet.context-path=/demo
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.yxxy.MyApp</mainClass> </configuration> </plugin> </plugins> </build>
RestController = @Controller+@ResponseBody
一个效果
@RestController public class MyAppController { @RequestMapping("/") public Map<String, String> index() { Map<String, String> map = new HashMap<>(); map.put("aaa", "bbb"); map.put("aaa", "bbb"); map.put("aaa", "bbb"); map.put("aaa", "bbb"); return map; }
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
@Controller public class IndexController { @RequestMapping("/") public String index(ModelMap map) { // 加入一个属性,用来在模板中读取 map.addAttribute("msg", "nihao~"); return模板文件的名称,对应src/main/resources/templates/index.html return "index"; } 模板文件代码 <h1 th:text="${msg}">hi!</h1>
UserRestfulController @RequestMapping("/") @RestController public class UserRestfulController { static Map<Long, User> users = Collections.synchronizedMap(new HashMap<Long,User>()); @RequestMapping(value="/User",method=RequestMethod.GET) public List<User> getUserList(){ ArrayList<User> list = new ArrayList<>(users.values()); return list; } @RequestMapping(value="User",method=RequestMethod.POST) public String addUser(@ModelAttribute User user) { users.put(user.getId(), user); return "addUser Success"; } } User public class User { private Long id; private String loginName; private String password; private String nickName; 注入Service UserRestfulController @Autowired private UserService userSrv; @RequestMapping(value="/User",method=RequestMethod.GET) public List<User> getUserList(){ return userSrv.getUserList(); } @RequestMapping(value="User",method=RequestMethod.POST) public String addUser(@ModelAttribute User user) { String msg = userSrv.addUser(user); return msg; } UserService @Service public class UserService { static Map<Long, User> users = Collections.synchronizedMap(new HashMap<Long,User>()); public List<User> getUserList() { ArrayList<User> list = new ArrayList<>(users.values()); return list; } public String addUser(User user) { users.put(user.getId(), user); return "addUser Success"; } }
<h1>User list</h1> <table> <tr> <th>NAME</th> <th>loginName</th> <th>nickName</th> </tr> <tr th:each="user : ${list}"> <td th:text="${user.id}">id</td> <td th:text="${user.loginName}">loginName</td> <td th:text="${user.nickName}">nickName</td> </tr> </table> <p> <a href="../home.html" th:href="@{/}">Return to home</a> </p>
Springboot项目必须要继承的parnet
进入本地库 for /r %i in (*.lastUpdated) do del %i 然后update
删掉 重新update
所有错误都解决后
Jar方式运行 首先得有这个jar包
先clean package 生成jar文件,然后再run main方法
把jre的路径换成jdk的
SpringBoot01——Framework Introduced and Helloworld
标签:本地 config arraylist src autowire group sem ora 错误
原文地址:https://www.cnblogs.com/littlepage/p/11031303.html