• 使用maven工具对maven项目进行打包所出现的问题


    使用maven工具对maven项目进行打包所出现的问题

    在Eclipse左侧右击项目,DebugAs -> Debug Configurations -> 双击Maven Build 然后看弹出框的右侧
    右侧的Name随便填写一个名字,
    Basedirectory 则选择项目路径
    Goals是Maven文档里会有说明的目标动作,一般填"cleaninstall"就是可以了。填的时候不要引号
    然后点击Debug
    ——————————————————————————————————————


    Maven就会开始打包了,打的包会放在与src同级的target目录下。

    如果这个项目对别的项目有依赖,则要先打包别的项目成,再打包当前项目。
    然后把这个目录下的内容放到服务器就好了。放好后要重启服务器上的tomcat才可以。

    问题:点击Debug,后报的第一个错误

    -source 1.6 中不支持 diamond运算符

    在pom.xml中加入代码搞定

           <plugin>

                    <artifactId>maven-compiler-plugin</artifactId>

                    <version>3.1</version>

                    <configuration>

                        <source>1.7</source>

                        <target>1.7</target>               

                    </configuration>

          </plugin>

    maven编译web项目显示“软件包 javax.servlet.http不存在"

    这是由于缺少servlet-api.jar包,其实tomcat下有,但是在Java buildpath把他加载过来,还是报这个错误,所以我们直接在pom.xml里面加入这个jar包即可,加入的代码如下:

    <dependency>

        <groupId>javax.servlet</groupId>

        <artifactId>servlet-api</artifactId>

        <version>2.5</version>

        <scope>provided</scope>

    </dependency>

    maven打包时出现非法字符: /65279错误

    在s抛出错误的文件上右键--》属性--》Resource-->Text file encoding-->选中‘UTF-8’-->点击Apply按钮-->点击OK按钮

    ,打包失败。

    方法2:使用UtilEdit工具或notepad++,

    将文件另存为-->选择“UTF-8”-->点击保存,重新打包,失败,

    仔细一看,原来UtilEdit保存格式中UTF-8是默认带有BOM的,需要选择“UTF-8- 无 BOM”的格式。

    打包后,成功。

    最后打包成功

    打包成功了

    放到tomcat下试一试

    结果。。。

    不能登录,排查后发现缺少xml 文件

     记录Maven和Mybatis整合时打包漏掉mapper的xml文件及其它资源

    已有

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    <resources>

                <resource>

                    <directory>src/main/java</directory>

                    <includes>

                        <include>**/*.properties</include>

                        <include>**/*.xml</include>

                    </includes>

                    <filtering>false</filtering>

                </resource>

            </resources>

    删除无用的配置

    右键项目 debug as àdebugconfigurations

  • 相关阅读:
    Codeforces Round #598 (Div. 3)(全)
    Codeforces Round #597 (Div. 2) F
    Codeforces Round #597 (Div. 2) D Shichikuji and Power Grid (MST)
    ACM bitset
    Codeforces Round #592 (Div. 2) E. Minimizing Difference
    Educational Codeforces Round 74 (Rated for Div. 2)D. AB-string
    Educational Codeforces Round 74 (Rated for Div. 2) tandard Free2play
    2018南昌邀请赛网络赛 单调栈 I
    rmq问题
    poj 3259Wormholes
  • 原文地址:https://www.cnblogs.com/llhl/p/9648709.html
Copyright © 2020-2023  润新知