那些年我们一起遇到的bug

1.检出SpringBoot项目时报错:

    1.先将jre依赖删除,再添加本地的jre.

    2.右键项目---> JavaEE  Tools ---> generate Deployment Descripter Stub  生成web.xml文件。

如果你修改了Java的jre版本(需要修改项目的编译环境【右键项目名-->properties-->Java Build Path--->libraries选项卡】和eclipse的编译环境【window-->preferences-->Java  --->copiler】),但是一旦Maven--->Update Project...   又变回了原来的版本,则在pom.xml中添加如下代码,修改默认编译的版本。   

<plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-compiler-plugin</artifactId>  
            <configuration>  
                <source>1.7</source>  
                <target>1.7</target>  
            </configuration>  
</plugin>

2.MyEclepse项目上有红叉但不影响运行的问题解决

可以该文章进行修改:https://blog.csdn.net/Flight_code/article/details/74516343

3.springboot项目报错:

        The type org.springframework.context.ConfigurableApplicationContext cannot be resolved。It is indirectly referenced from required .class files

问题是出现在maven中缓存上,maven的缓存已损坏

按照以下步骤解决:
    在命令行中转到项目目录。
    确保您的POM.xml与您的命令行在同一个目录中
    运行命令 mvn dependency:purge-local-repository
    如果您收到构建成功的消息,表示错误已解决。
    如果仍然存在错误,请删除(〜/ .m2 / repository / org / springframework)文件夹并运行 mvn package
    如果存在红色的叹号,则将原来的jre删除,重新添加即可

4.springboot正常启动,但是编写controller之后无法访问?

    1.首先检查编写的controller是否在启动类的同包或者是子包下,否则无法访问;  如:启动类在com.demo 包下,则controller必须在com.demo.*包下

    2.检查访问的地址是否正确,  访问地址  ip地址:端口号/窄化请求.do                       //窄化请求也就是ReequestMapping()中的地址

5.检出项目,Java代码报错,其中一个错误:

    The method convert(byte[], int, int, char[], int, int) from the type ByteToCharUTF7 refers to the missing type ConversionBufferFullException
  原因:jdk版本太高,高版本可能删除了低版本的方法
  解决:安装低版本jdk,在eclipse中引入(window-->preferences-->Java---->Installs JREs-->点击add按钮添加jdk)
 
6. 检出项目,使用tomcat运行,报数据库的错误
    原因:tomcat中没有相关的jar包

    解决:在tomcat中添加相关的jar包即可(找到tomcat的安装路径---》conf---》catalina.properties,添加相关的jar包,再重启即可)

7.Unable to process Jar entry [COM/ibm/db2os390/sqlj/custom/DB2SQLJProfile.class] from Jar [jar:file:/D:/javaDev/JavaWorkSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/moamess/WEB-INF/lib/db2jcc-9.1.jar!/] for annotations

org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file

解决:  1.  https://blog.csdn.net/qq_38005982/article/details/77113453

            2.如果上面的方式不行则安装tomcat 8, 如果还报错使用tomcat 8  进行上面的操作。

8.Multiple annotations found at this line:  

  - The method getServletContext() is undefined for the type __2F_moamess_2F_WebContent_2F_index_2E_jsp     - ServletContext cannot be resolved to a type

可能是jdk的版本或者是tomcat没有在 buildPath中绑定(右键项目---》build path--->configure build path,之后进行jdk版本的修改之类的操作)

9.  Project facet Java version 1.8 is not supported(在运行tomcat,添加项目到tomcat时)

    原因:jdk的版本和项目的版本可能冲突。

    解决:window---->preperences---->Java--->Installed JREs----->选择合适的版本

10. 从svn检出maven项目报错: xxx cannot be resolved
        原因:pom.xml文件中没有依赖。
        解决:到maven的官网找依赖(直接百度maven),添加了依赖之后可能还是不行,
                    那么就clean项目,maven--->update project;

                    如果还是不行就更改依赖的版本,有可能是版本的问题。

11. Action无法被解析成bean?

        原因:set注入时,action中的属性名和service中的bean的id的名称不同(在action中注入是比较特别的)导致的。

                   如果是其他注入,比如说dao注入到service中,属性名不必和bean的

12.编写发送邮件遇到的错误:

        javax.mail.MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 465;

        java.net.ConnectException: Connection timed out: connect

        如果是上面的两个错误有可能是

                    1.在公司内网,无法访问。换成外网再次尝试

                    2.有可能是端口的问题,如果是QQ ,则可以将端口换成 587

     Caused by: javax.mail.AuthenticationFailedException
      at javax.mail.Service.connect(Service.java:319)

     at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)

     出现这个错误是因为密码错误,

        重点要来了,这个密码不是你的QQ密码,而是授权码

        因为这个程序就相当于第三方程序,所以要授权码

13、数据库连接问题:先检查网线是否插好,再检查数据库的地址和端口是否正确。
14、页面404   有可能是ftl页面有些文件没有加载出来(例如:js的文件地址没有书写正确,没有加载出来)

如有侵权或其他问题,请在评论中留言通知我,谢谢!

15、使用 json 格式向后端传递参数,但是为null ,原因:没有在形参上添加 @RequestBody

16  .mybatis的框架下出现的问题:

Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML.
Cause: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType.
Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.String

<result column="constPeriod" property="constPeriod" jdbcType="String" />
原因:jdbcType对应的是VARCHAR,而不是String (并且要全部大写)


org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'EQUIP_TYPE' in 'class com.markash.bootbatis.entity.BusinessBaseEntity'

resultMap标签中的  类名  和 对应的 实体类 不对

猜你喜欢

转载自blog.csdn.net/ke_mo_duo/article/details/80014082