idea+Maven+Git使用步骤

idea+Maven+Git使用步骤,第1张

接上一篇Maven项目新建

1. 对于新建的Maven项目 第一步File–>Settings里面看一下有没有git.ext

以下是步骤
  1. 点击VCS–>Import into Version Control–>Create Git Repository–>选择你当前项目的路径–>点击ok,会自动在你的路径下面添加.git文件

  2. 项目名称右键–>show in Explorer,查看可以看到新添了.git文件

  3. 再次点击VCS–>Commit,然后把你要提交的文件选中,写个注释

  4. 默认是master,在项目右下角Git:master可以改

  5. push项目前新建忽略文件

  6. 我们把项目push到我的Github或者是Gitee账户的仓库上时,有部分文件是不需要的push的

  7. 项目名称右键–>New–>File–>命名.gitignore

pom.xml
  1. 在src目录下的.xml文件在项目运行中,不会加载到target中,会导致找不到.xml文件
    将xml文件复制到target的classes目录中,并在查询运行时正确读取
    pom.xml中新建build标签,添加如下

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>com.qfgroupId>
    <artifactId>hello-mybatisartifactId>
    <version>1.0-SNAPSHOTversion>

    <dependencies>
        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
            <version>3.4.6version>
        dependency>
        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.47version>
        dependency>
        
        <dependency>
            <groupId>log4jgroupId>
            <artifactId>log4jartifactId>
            <version>1.2.17version>
        dependency>

    dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/javadirectory>
            <includes>
                <include>*.xmlinclude>
                <include>**/*.xmlinclude>
            includes>
            <filtering>truefiltering>
        resource>
    resources>
build>

project>
VCS–>Git–>push

  1. 点击Push

  2. 我的gitee是
  3. 复制过去,Push就行了!
  4. 有一个报错
  5. maven路径给错了?
  6. 重新去Settings去设置
  7. 再次push还是不对
  8. 在terminl窗口中依次输入命令:

git pull

git pull origin master

git pull origin master --allow-unrelated-histories

  1. 再次push 成功!
日志查看

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/langs/732859.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存