常用配置
maven 相关
新建maven巨慢
-DarchetypeCatalog = internal
跳过测试
此时已然需要编译测试类,如果需要编译时跳过测试类,可以:
mvn install -Dmaven.test.skip=true
或者
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
自身配置
显示运行时占用内存
旧版本;
新版本:
方法一:
双击shift,搜索show memory indicator
打开后重启,右下角显示IDEA内存占用情况
方法二:
不打开上次项目
settings->Appearance & Behavior -> System Settings 取消 Reopen last project on startup
properties 文件编码
隐藏文件
File->Settingss->Editor->File Types
找到.ignore
添加 .idea;
*.iml
编辑器
背景色
settings -> Editor -> Color Schema -> General -> Text -> Default text 修改 Background
缩进线与右侧80列线
颜色
settings -> Editor -> Color Schema -> General -> Editor ->Guides
Hard wrap guide : 右侧线颜色
Indent guide : 缩进线 颜色
位置
settings -> Editor -> Code Style -> Hard wrap at
mapper xml 颜色
步骤一
Settings -> Editor -> Inspections -> SQL
取消勾选:No data sources configured 和 SQL dialect detection
步骤二
spring 等提示
mapper 报错
方法一:
方法二:
直接将@Autowired换成@Resource注解,此注解是JDK中的注解,不会向@Autowired那样去Spring容器中寻找bean
Field injection is not recommended
方法一:
方法二:
spring 官方推荐
private final ProductCateLogic productCateLogic;
@Autowired
public ProductCateController(ProductCateLogic productCateLogic) {
this.productCateLogic = productCateLogic;
}
方法三:
private ProductCateLogic productCateLogic;
@Autowired
public void setProductCateLogic(ProductCateLogic productCateLogic) {
this.productCateLogic = productCateLogic;
}
方法四:
该方法有几率导致Spring循环引用问题,所以还是不推荐使用
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ProductCateController extends BaseController {
private final ProductCateLogic productCateLogic;
拼写检查
旧版本:
新版本:
生成代码
基本使用
-
选中要生成的代码,
-
从菜单中选择Tools | Save as Live Template
-
填写触发单词(Abbreviation)
-
在代码中输入触发单词后按Tab,可以重复生成代码片段
新建类添加注释
/**
*
* @author ${USER}
* @date ${YEAR}-${MONTH}-${DAY} ${TIME}
* @version 1.0
*
*/
生成 logger
类似
/**
* logger
*/
private static final Logger LOGGER = LoggerFactory.getLogger(AccessFilter.class);
然后点击标记2的选项,在弹出的对话框中填入代码组名称
这里我填入的自定义名称是AI_qnloft,然后选择我们刚刚建立的代码组,点击之前标记3的选项,在代码组中新增自定义代码。
选择代码语言:
填入完成后的样子:
C
L
A
S
S
CLASS
CLASS函数会自动填入当前类名称,但是需要设置一下,点击上图Edit variables按钮
完成
常用插件
maven helper
code glance
Alibaba Java Coding Guidelines https://github.com/alibaba/p3c
mybatisx
mybatis log plugin
RestfulToolkit 【全局搜索 Ctrl + \】
无法显示 Run Dashboard 的解决方法
1、进入项目,找到 .idea/workspace.xml 文件
2、找到 <component name="RunDashboard">
,增加以下内容
<option name="configurationTypes">
<set>
<option value="SpringBootApplicationConfigurationType" />
</set>
</option>
3、重启
profile
本次运行maven需要哪个profile就选中哪个profile
maven 运行配置需要加上 -P参数
tomcat + maven profile
配置 maven install
新建一个javaweb项目
目录结构
pom.xml
<profiles>
<profile>
<id>km-ssm-dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
</profile>
<profile>
<id>km-ssm-test</id>
<properties>
<profiles.active>test</profiles.active>
</properties>
</profile>
</profiles>
添加maven启动项
配置 tomcat
选择浏览器
点击 fix
选择 exploded
回到 server ,选中 update classes and resources
选择之前的 maven install
选中profile
日志位置
catlina.out
C:\Users\Administrator\.IntelliJIdea12\system\tomcat
logback日志位置
安装的tomcat的log目录下
设置单击打开文件或者双击打开文件、自动定位文件所在的位置
Found duplicated code
File → Settings → Editor → Inspections → General → Duplicated Code.
快捷编辑
列编辑
Alt + 鼠标
替换空白行
^\s*\n