IDEA 格式化SQL代码技巧分享

网友投稿 290 2023-01-29

IDEA 格式化SQL代码技巧分享

写在前面

IntelliJ IDEA集成了很多我们开发中常用的工具,linux连接,Git,数据库操作…

这里我们介绍,IDEA集成数据库操作,并对SQL可格式化…

通过命令,但是在合适的执行文件中…

Ctrl Alt L

1.1、建立连接,数据库服务器地址,账号,密码等…

1.2、基本操作,很http://多,增删改查,控制台SQl编写等等

SQL执行控制台,这里是格式化之后的,我们平时手写的SQL都是没有格式化的,注意这里提供了输入框,操作占位符的参数也很方便…

那么这里的格式化的SQL是怎么实现的呢??

这里的哈,IDEA的快捷键 Ctrl + Alt + L,就可以格式化SQL

补充:解决idea的src目录下不能编译SQL语句的xml配置文件的问题

一:正常配置下的情况

1.编译的目录下不会编译映射配置文件.xml,但是resources目录中的文件都被编译出来。

2.pom.xml文件的配置

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.sly

hrm01

1.0-SNAPSHOT

war

hrm01 Maven Webapp

http://example.com

UTF-8

1.7

1.7

junit

junit

4.11

test

org.aopalliance

com.springsource.org.aopalliance

1.0.0

org.aspectj

com.springsource.org.aspectj.weaver

1.6.4.RELEASE

org.springframework

spring-aop

5.0.10.RELEASE

org.springframework

spring-aspects

5.1.0.RELEASE

org.springframework

spring-beans

5.0.1.RELEASE

org.springframework

spring-context

5.0.1.RELEASE

org.springframework

spring-core

5.0.1.RELEASE

org.springframework

spring-expression

5.0.1.RELEASE

org.springframework

spring-jcl

5.0.1.RELEASE

org.springframework

spring-jdbc

5.0.1.RELEASE

org.springframework

spring-tx

5.0.1.RELEASE

org.springframework

spring-web

5.0.1.RELEASE</version>

org.springframework

spring-webmvc

5.0.1.RELEASE

org.mybatis

mybatis

3.4.2

org.mybatis

mybatis-spring

1.3.1

mysql

mysql-connector-java

5.1.48

com.alibaba

druid</artifactId>

1.1.5

javax.servlet

jstl

1.1.2

taglibs

standard

1.1.2

org.apache.tomcat

tomcat-servlet-api

9.0.21

hrm01

maven-clean-plugin

3.1.0

maven-resources-plugin

3.0.2

maven-compiler-plugin

3.8.0

maven-surefire-plugin

2.22.1

maven-war-plugin

3.2.2

maven-install-plugin

2.5.2

maven-deploy-plugin

2.8.2

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.sly

hrm01

1.0-SNAPSHOT

war

hrm01 Maven Webapp

http://example.com

UTF-8

1.7

1.7

junit

junit

4.11

test

org.aopalliance

com.springsource.org.aopalliance

1.0.0

org.aspectj

com.springsource.org.aspectj.weaver

1.6.4.RELEASE

org.springframework

spring-aop

5.0.10.RELEASE

org.springframework

spring-aspects

5.1.0.RELEASE

org.springframework

spring-beans

5.0.1.RELEASE

org.springframework

spring-context

5.0.1.RELEASE

org.springframework

spring-core

5.0.1.RELEASE

org.springframework

spring-expression

5.0.1.RELEASE

org.springframework

spring-jcl

5.0.1.RELEASE

org.springframework

spring-jdbc

5.0.1.RELEASE

org.springframework

spring-tx

5.0.1.RELEASE

org.springframework

spring-web

5.0.1.RELEASE</version>

org.springframework

spring-webmvc

5.0.1.RELEASE

org.mybatis

mybatis

3.4.2

org.mybatis

mybatis-spring

1.3.1

mysql

mysql-connector-java

5.1.48

com.alibaba

druid</artifactId>

1.1.5

javax.servlet

jstl

1.1.2

taglibs

standard

1.1.2

org.apache.tomcat

tomcat-servlet-api

9.0.21

hrm01

maven-clean-plugin

3.1.0

maven-resources-plugin

3.0.2

maven-compiler-plugin

3.8.0

maven-surefire-plugin

2.22.1

maven-war-plugin

3.2.2

maven-install-plugin

2.5.2

maven-deploy-plugin

2.8.2

3.控制台无报错且网页报错404 找不到,或者500如下错误。

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userHandler': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IUserDao' defined in file [D:\Tomcat\apache-tomcat-9.0.27\webapps\hrm01_war\WEB-INF\classes\com\hrm\user\dao\IUserDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'com.hrm.user.dao.IUserDao' but found 'com.hrm.user.dao.UserDao'.

二、解决方案

1.在pom文件中的build标签下配置该属性即可解决这个问题,但是要注意src前面不要加 / 。

一定不要写为:(/src/main/java)。

这样在编译目录下xml文件也被编译。

2.加入该配置后编译目录下有了映射配置文件,见上图IUserDao.xml。

控制台可以正常显示数据。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:话费充值api(话费充值api接口申请)
下一篇:教育类免费api(教育类免费发论文的期刊)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~