boot idea无法识别spring_同学,其实用免费版的IDEA来创建SpringBoot项目挺方便的......

本文介绍了如何使用IntelliJ IDEA 社区版创建SpringBoot项目,包括环境配置、新建Maven项目、配置目录、设置文件夹属性、配置pom.xml和application.properties,以及创建启动类和控制器。通过遵循这些步骤,即使IDEA未自动识别SpringBoot,也能成功创建项目。
摘要由CSDN通过智能技术生成
作者:TisFreedom 来源:http://bit.ly/2N0DXaR

# springboot项目资源:

GitHub地址:https://github.com/TisFreedom/springbootdome.git码云地址:https://gitee.com/TisFreedom/springbootdome.git

1.环境配置(jdk、maven、idea社会版)这里我就不再详细讲解。

2.新建maven项目。File>New>Project>Maven>Create from archetype>Maven-archetype-webapp>Next

0ac4cda7d9f210e8ddd816438d033c15.png

3.填写GroupId和ArticleId 然后Next

87d44b42216d1b556a6910c1120a5873.png

4.配置自己的maven(如果你没有用默认的也行),完事Next

0f2c938d19352b9a6d19051b67851de6.png

5.确认项目存放目录,然后Finish

b00db3a2fa6fc9bee856ffb822b22513.png

如果右下角出现这个东西,麻烦你点一下Import Changes。

01c09c0969df6976b67e9144fa40d296.png

会生成标准的web项目目录,当然会少java目录和resource目录

694fe22d8a1b87815ebdd14185e461ea.png

6.新建java目录和resource目录

9f1bf54fda71d4709ba28a5c9baab85e.png
2df5ec52e75df884c9785f1da736f105.png

这样就建好了,当然idea是无法识别这些文件夹是干嘛。所以需要手动设置。

选中文件夹>左键>Mark Directory as

java文件夹选 Sources Root

resources文件夹选 Resources Root

03c943398f18cc5d302b525d2ec6e1f5.png

7.配置pom.xml

 org.springframework.boot spring-boot-starter-parent 1.5.6.RELEASEorg.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat org.apache.tomcat.embed tomcat-embed-jasper org.mybatis.spring.boot mybatis-spring-boot-starter 1.1.1mysql mysql-connector-java org.springframework.boot spring-boot-starter-log4j2 javax.servlet jstl taglibs standard 1.1.2org.springframework.boot spring-boot-devtools truetrueorg.springframework.boot spring-boot-maven-plugin  true

8.配置application.properties文件

如果配置访问前缀后缀要建立相应的目录和视图

#修改端口server.port=80 #数据源相关配置spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8spring.datasource.username=rootspring.datasource.password=123spring.datasource.driver-class-name=com.mysql.jdbc.Driver #访问前缀和后缀spring.mvc.view.prefix=WEB-INF/jsp/spring.mvc.view.suffix=.jsp mybatis.mapperLocations=classpath:com/springboot/mapper/xml/**/*.xml

9. 新建启动类

@SpringBootApplication//扫描控制器类@ComponentScan(basePackages="com.springboot")//扫描dao@MapperScan(basePackages="com.springboot.mapper")public class SpringBootStart { public static void main(String [] args){ SpringApplication.run(SpringBootStart.class,args); }}

10.新建控制器

@Controllerpublic class TestController { @RequestMapping("/") public String index(Model model, HttpServletResponse response) { return "index"; }}

你的目录应该是这样子的

3b1587bb8201d439688ec4b5f531c410.png

11.启动访问

4f7b3511b3c187ca8e8e85ade10bc4e0.png
28264fe3ea753b2d83d364ee81d928f2.png

如果你也向我一样配置了端口,和控制器默认路径。name自接用 localhost 就能访问。

如果你配置失败了,通过github或者码云去下载源码查看。谢谢阅读!!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值