接上一篇Maven项目新建
1. 对于新建的Maven项目
第一步File–>Settings里面看一下有没有git.ext
以下是步骤
点击VCS–>Import into Version Control–>Create Git Repository–>选择你当前项目的路径–>点击ok,会自动在你的路径下面添加.git文件
项目名称右键–>show in Explorer,查看可以看到新添了.git文件
再次点击VCS–>Commit,然后把你要提交的文件选中,写个注释
默认是master,在项目右下角Git:master可以改
push项目前新建忽略文件
我们把项目push到我的Github或者是Gitee账户的仓库上时,有部分文件是不需要的push的
项目名称右键–>New–>File–>命名.gitignore
pom.xml
- 在src目录下的.xml文件在项目运行中,不会加载到target中,会导致找不到.xml文件
将xml文件复制到target的classes目录中,并在查询运行时正确读取
pom.xml中新建build标签,添加如下
<?xml version="1.0" encoding="UTF-8"?>
<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.0</modelVersion>
<groupId>com.qf</groupId>
<artifactId>hello-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 导入依赖-->
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<!-- 将xml文件复制到classes中,并在查询运行时正确读取 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>*.xml</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
VCS–>Git–>push
- 点击Push
- 我的gitee是
- 复制过去,Push就行了!
- 有一个报错
- maven路径给错了?
- 重新去Settings去设置
- 再次push还是不对
- 在terminl窗口中依次输入命令:
git pull
git pull origin master
git pull origin master --allow-unrelated-histories
- 再次push 成功!
日志查看
版权声明:本文为m0_47010003原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。