Ssm integration with maven stepped pit

prologue:

  After studying spring + springmvc + mybatis framework, and wrote a small project. Now that almost most companies are using maven to develop, because there are many benefits of using maven Development (interest themselves to Baidu). So recent study maven, I do not know when we learn maven is like mentality, and I looked after a lot of people blog, the mentality is: This is too simple of it, not that import dependence, packaged items posted to the server Well. It now appears, in fact, maven is not difficult, but there are many pit, Here, I will share my stepped pit, probably because my own reasons, and in this essay you might look at this life will not We met, purely to share.

 A pit:

I do not know if you learn how to find maven time is dependent, a project jar kits too much, it will rely on to import more than death. At first, I was going to import one package go to Baidu search, to find it maven, this really tm tired, but by Baidu many times I have found a way to quickly find dependencies: jar your direct input in the search box the package name + space + maven can quickly find, for example, I am looking rely on spring-core, then enter the "spring-core maven" will be able to quickly find the (right here for me to step on pit foreshadowed) as shown:

Select the version you want, you can get dependent on:

Then came the pit, after completion of the integration ssm, there has been an exception, as shown:

Baidu, you will find this error, human actions can not, here to cite the brothers blog

https://blog.csdn.net/qq_35764460/article/details/87289602

It is worth noting:

The cause of this problem is:

 Yes, he is the first to pop up before

 The solution is: this will not be such a search, go directly to the official website maven provide dependent: https://mvnrepository.com

Episode:

Prior to this, there are many problems yet, one of which makes me wonder is this question:

Complete integration with maven ssm project, the first error is this:

This report led to the wrong process:

After accessing your project, error:

这个错误至今我也没找到解决的办法,怀疑是Tomcat版本太低,怀疑的根据:Apache Tomcat/6.0.29(如上图所示),考虑过修改maven选择的Tomcat版本,但没成功。先不管了,这种不行,就换另一种解决方案,直接maven install,打好的包放到服务器上(这样调试的话很智障)。我把编译工具换成了idea,这个错误也能避免(现在还在纳闷中。。。)

 坑二:

 报错是这样的:

 

这里要引用一下这位兄台的博客:https://blog.csdn.net/dynastyting/article/details/83279758

它里面的方法二解决了我这个问题

插入这段代码:

        <!--配置Maven 对resource文件 过滤 -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>    

总结:

经历过一堆问题后回过头写这篇随笔,感觉这些坑好简单,但在自己经历的过程中你就会发现并没有想象中的简单,maven我花了两天的时间,原本以为最多一天搞定,现在想想,自己其实犯了很多错,比如在排查bug的时候没想到将异常抛出,而是在琢磨配置文件,之前没修改的异常抛出是这样的:

显示给用户看的是这样的:

此次教训给了我很多启迪,这样也能让我成长的更快,所以感谢犯错!!!

 

Guess you like

Origin www.cnblogs.com/xiaoqiangwu/p/11297435.html