Idea使用中的问题记录

idea配置Tomcat,启动Web项目

  1. Run->Edit Configuration
  2. 添加TomcatServer->Local Server,在Server选项卡中选择Tomcat服务器,并进行Tomcat名称,默认部署后启动的浏览器等信息
    • 编辑器已有默认配置
  3. 选择Deployment选项卡,按绿色+号 添加需要部署的项目,右侧Application context为项目名称.
    • 如果Application context不配置,默认为/,那么通过http://localhost:8080/index.jsp即可访问项目页面
    • 如果Application context配置为/test,那么访问路径变为http://localhost:8080/test/index.jsp

注意

如果发现配置的部署的项目无法Apply,或者无法通过绿色铅笔按钮进行编辑 , 那么采用如下方法:

  • idea编辑器左上角File->Project Structure->Project Settings->Artifacts->绿色按钮添加->Web Application Exploded
  • 左边output root为编译文件输出目录 , 右侧Available Elements为可用项目元素 , 默认编辑器已配置好可用项目元素 , 双击 , 或右键选择 , 即可将指定目录左移到output root目录.
  • 回到Edit Configuration->Deployment界面 , 重新添加部署的项目 , 来源选择Artifacts即可

4.此时Apply之后发现tomcat并没有添加成功 , 还差最后一步 . 在Edit Configuration页面下方 , 有Befor launch:Build,Build Artifacts,Activate tool window选项 , 默认只有一个Build条目 , 再添加一个Build Artifacts条目 , 再Apply->OK

配置成功!完事!

错误:找不到或无法加载主类

环境状况:

  • 环境变量配置没有问题,通过windows命令行窗口可以正常查看版本号
  • 电脑里的其他Java和Android项目都运行正常

在此前提下,运行Demo时报出 错误:找不到或无法加载主类. 说明是Idea配置问题导致的.

原因

  1. 没有给Project设置编译文件的输出路径,即Project Structure -> Project Settings -> Project compiler output没有设置,但是却在Modules -> Paths 中选择了 Inherit project compile output path
  2. Project Structure -> Modules -> Paths 中,选择了Use module compile output path , 但是只是默认的相对路径.

解决方案

首先,确保Project Structure -> Project,已为Project指定SDK

其次:

方案1:使用Project的编译输出路径

  • 在Project Settings -> Project compiler output中设置Project的编译输出路径
  • 在Project Settings -> Modules中选择 Inherit project compile output path 即继承Project的路径

方案2:使用Module的编译输出路径

Project Structure -> Modules -> Paths,改变Output pathTest output path的路径.

两个路径默认是:

  • \out\lib
  • \out\test\lib

改为项目绝对路径+上述目录,比如项目文件路径为E:\JavaEE\HelloWorld,那么修改后的两个Path分别为:

  • E:\JavaEE\HelloWorld\out\lib
  • E:\JavaEE\HelloWorld\out\test\lib

实现接口方法报错

当实现一些接口方法时,报出@Override is not allowed when implementing Interface method

override报错.png

由于项目所使用的java语言版本所导致的,打开File->Project Structure->Modules->选择项目目录->Sources选项卡->Language Level,更换Language Level即可,比如更换为8-Lambdas. 即可解决问题,如下图所示

更换LanguageLevel.png

pom.xml中配置的依赖库提示not found

情况1:maven Reposity 仓库里有
解决:右键–>Maven–>Reimport , 搞定

情况1:maven Reposity 仓库里没有,比如一些第三方服务商的库
解决: 将jar包安装到本地仓库 , 见maven安装及添加本地jar包到maven仓库 ,重新build即可

mybatis的Mapper和xml关联失败,找不到xml文件

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.crocutax.mybatisdemo.mapper.UserMapper.findUserList

	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225)
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)

解决方案:在pom.xml中配置

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
    </resources>
</build>

参考 http://blog.csdn.net/shifangwannian/article/details/48882201

webxml attribute is required

maven构建时报异常,信息如下:

webxml attribute is required (or pre-e xisting WEB-INF/web.xml if executing in update mode

原因:maven管理的web项目,默认会去src/main/webapp目录下寻找WEB-INF/web.xml文件,因此web项目的文件转移到该目录即可.

参考:http://blog.csdn.net/lizhitao/article/details/25213669

java.lang.NoClassDefFoundError: javax/el/ELManager

原因:缺少javax.el-api仓库依赖

解决:在pom.xml中添加javax.el依赖即可

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>
</dependency>

参考链接:https://stackoverflow.com/questions/45841464/java-lang-noclassdeffounderror-javax-el-elmanager

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
使用Git来管理你的Idea项目时,你可以按照以下步骤进行操作: 1. 初始化Git仓库:在Idea项目的根目录下打开终端或命令行工具,运行命令 `git init` 来初始化一个新的Git仓库。 2. 添加文件到暂存区:使用命令 `git add <文件名>` 将你的项目文件添加到Git的暂存区,例如 `git add app.py`。 3. 提交更改:运行命令 `git commit -m "提交描述"` 来提交你的更改到Git仓库,例如 `git commit -m "添加新功能"`。这将会创建一个新的提交记录。 4. 创建分支:如果你想在开发新功能或修复bug时创建一个新的分支,可以使用命令 `git branch <分支名>`,例如 `git branch feature-branch`。切换到新分支可以使用 `git checkout <分支名>`。 5. 合并分支:当你在新分支上完成开发后,可以将其合并到主分支(通常是`master`或`main`分支)。切换回主分支使用 `git checkout <主分支名>`,然后运行命令 `git merge <分支名>` 将新分支的更改合并到主分支。 6. 远程存储库:将本地的Git仓库与远程存储库(如GitHub、GitLab等)关联,可以使用命令 `git remote add origin <远程仓库地址>`,例如 `git remote add origin https://github.com/yourusername/your-repo.git`。然后通过 `git push -u origin <分支名>` 将本地分支推送到远程仓库。 这些是使用Git管理Idea项目的基本步骤。Git还有更多功能和命令,可以根据需要进行学习和使用

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Crocutax

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值