IntelliJ IDEA导入Gradle项目,并启动项目

一、安装gradle,参考上一篇安装gradle

二、导入gradle项目

1.选择菜单栏的File->new->Project from Existing Sources...
2.在打开的窗口选择对应Gradle项目的build.gradle文件,然后点击OK。
3.在Open Project窗口中,点击Open as Project。
4.选择菜单栏的File->Settings,搜索gradle,选择一下配置
5.在gradle.properties配置java.home
6.在setting.gradle里配置要构建的工程
7.配置项目里的build.gradle里的tomcat目录,每个项目都需要配置
8.配置tomcat,选择tomcat的安装目录
9.添加服务,并更改启动名称
10.启动项目
11.启动报错not found for the web module

原因:因为Gradle编译器不会给你自动创建exploded目录,但是Tomcat找的时候是去哪个目录找的,所以改回用IDEA做编译器


这样就能正常生成exploded目录,启动正常了
12.启动过程中遇到java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

原因:idea运行tomcat内存过小解决办法:调整内存
在edit configurations->tomcat-> server中,
配置VM options即可。
-server -Xss2M -XX:PermSize=256M -XX:MaxPermSize=512m -Dfile.encoding=UTF-8

  • 12
    点赞
  • 50
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
您的问题是如何使用Spring Boot、Gradle和多模块来启动和编译项目,以及如何在IntelliJ IDEA中进行设置。下面是一个简单的步骤: 1. 创建一个Gradle多模块项目 在命令行或IntelliJ IDEA中创建一个Gradle多模块项目。在项目的根目录下创建一个settings.gradle文件,并将所有子模块列出来,如下所示: ``` include 'module1' include 'module2' ``` 然后,在每个子模块的build.gradle文件中,添加以下内容: ``` plugins { id 'org.springframework.boot' version '2.3.2.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' } ``` 2. 配置Spring Boot应用程序 在每个子模块中,创建一个Spring Boot应用程序。在每个应用程序的启动类中,添加@SpringBootApplication注释。例如: ``` @SpringBootApplication public class Module1Application { public static void main(String[] args) { SpringApplication.run(Module1Application.class, args); } } ``` 3. 配置Gradle编译和运行 在根目录的build.gradle文件中,添加以下内容: ``` subprojects { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.example' version = '0.0.1-SNAPSHOT' repositories { mavenCentral() } dependencies { testCompile('org.springframework.boot:spring-boot-starter-test') } springBoot { mainClassName = 'com.example.module1.Module1Application' } } ``` 上述代码设置了所有子模块的通用设置,如依赖项和主类。在每个子模块的build.gradle文件中,添加以下内容: ``` dependencies { implementation project(':module2') } ``` 上述代码添加了对另一个子模块的依赖关系。 4. 在IntelliJ IDEA中设置 在IntelliJ IDEA中,选择File > New > Project From Existing Sources,然后选择项目的根目录。在导入项目的向导中,选择“Gradle”作为项目类型,并设置Gradle的路径。然后,点击“Finish”按钮。 在IntelliJ IDEA的“Gradle”选项卡中,选择所有子模块,并点击“Refresh Gradle Project”按钮。 5. 启动Spring Boot应用程序 在IntelliJ IDEA中,选择需要启动的Spring Boot应用程序的启动类,并点击“Run”按钮。Spring Boot应用程序将在IDEA的内置Tomcat服务器上启动。 以上就是使用Spring Boot、Gradle和多模块来启动和编译项目,以及在IntelliJ IDEA中进行设置的基本步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值