当前位置:   article > 正文

idea基础环境相关的一些问题_the following file has staged content different fr

the following file has staged content different from both the

如果使用mac电脑,安装spectcle,对窗口进行分屏,这样年轻的时候可以同时做很多事情,效率迅速提升上去。
有的时候,发现导入的module,不显示是一个maven工程,则需要按照下图操作,将勾去掉即可
2

1 插件
1.1 git
有的时候工程使用git命令是没有问题的,但是idea中选中项目,点击鼠标右键,却没有显示git选项。出现这个问题,就需要进入到verson control将项目添加进来,就可以了。
2

码云,因为gitee可以免费构建自己的私有仓库
1
通过 SVN Disconnect插件,再参考IDEA取消SVN关联,在重新分享项目,以后就不用在自己mac上面启动svn了,直接上传代码到gitee上
在这里插入图片描述
.ignore插件,可以方便添加文件到忽略里面

1
ignore插件会生成一些忽略的模板,不过在使用ignore插件的时候也不是那么顺利,如果创建ignore的模板可以参考idea中.ignore插件的使用
按照别人说的,执行第一个命令就报错了,提示

F:\bazi\qingqiu>git rm -r --cached .
error: the following file has staged content different from both the
file and the HEAD:
    .idea/workspace.xml
(use -f to force removal)
  • 1
  • 2
  • 3
  • 4
  • 5

调整策略,执行git rm -r -f --cached .之后git add .,这两个文件夹的颜色就不一样了,已经被git忽略了.
1
切换账号

192:~ dzm$ git config user.name
testhust
192:~ dzm$ git config user.email
2045657028@qq.com
192:~ dzm$ git config --global user.name "hello"
192:~ dzm$ git config --global user.email "393056998@qq.com"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

通过idea导入,提示403错误。
1
实际上是没什么问题,于是采取另外一种方式,创建一个工程名字,接着修改config文件,调整为git对应的地址,即可。因为gti可以控制到项目及,还是要靠config设置账号、密码及访问地址。
公司如果换环境怎么办呢,质量管理部强大的时候,购买了付费的极狐,质量管理部可有可无的时候,自己搭建gitlab也能解决问题。有些付费功能也用不上。但这些带来新的问题,现在代码在我本地如何切换到gitlab上呢?命令如下

# 查看当前项目的远程仓库地址
git remote -v
# 删除当前项目与旧的GitLab项目的关联
git remote remove origin
# 将当前项目与新的GitLab项目关联
git remote add origin http://10.8.15.226:8888/eayc/eayc/micro/wcn.git
# 注意master是一个分支名称,你可以按照你自己的来
git branch -M master
# 先拉
git pull origin master --allow-unrelated-histories
# 后推
git push -uf origin master

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

如果gitlab的分支默认不是master,而是main,则可以按照如下步骤更改
1 先创建master分支
1
2 因为main分支被protected了,故而需要更改他的属性,修改默认分支为master
2
3 修改保护分支,进入到Protected branches,将main分支的保护权限去掉
2
4 删掉main分支,因为main没有被protect,因而可以删除了
1当然每次这么做,岂不是很麻烦,你可以切换到顶级group,再这个地方修改后,它下面的project,都按照改后的名称来
2

如果提示下面的问题,这个是新工程

D:\appworks\javawork\tywork\einv\einv-complex-server>git push -uf origin master
error: src refspec master does not match any
error: failed to push some refs to 'http://10.8.15.226:8888/eayc/einv/micro/einv-complex.git'
  • 1
  • 2
  • 3

解决方案是:

# 查看当前项目的远程仓库地址
git remote -v
# 下面是新建工程提交
git init 
git remote add origin http://10.8.15.226:8888/eayc/einv/micro/einv-invoice-ext.git
git pull origin master --allow-unrelated-histories
git add .
git commit -m '首次提交'
git push -u origin master
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

切换分支

# 切换到develop分支
git checkout develop
git pull origin develop --allow-unrelated-histories
# 切换到master分支
git checkout master
git merge develop
git commit -m "Merge feature_branch into master"
git push origin master
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

1.2 Easy code
IDE工具(23) EasyCode代码生成器的使用教程(idea安装配置),以前吭哧吭哧写了一个代码生成器,现在有这么个插件,人家的好,自己的直接废弃,虽然用了5年可惜,但是搞技术的人不就应该与时俱进吗?
2
发现冲突
1
解决思路,打开VS Code(或你选择的文本编辑器),手动编辑冲突文件。在文件中,你会看到类似于<<<<<<<、=======和>>>>>>>的标记它们之间的内容表示了不同分支上的更改。你需要决定保留哪些更改或合并它们,然后移除这些特殊的标记。然后执行下面得命令

git status
git add .
git commit -m '解决冲突'
git push origin master
  • 1
  • 2
  • 3
  • 4

切换某一个分支的部分文件过来,按照下图指示,注意分支路径

 git checkout remotes/origin/ntacc -- src/views/invoice/income/index.vue
  • 1

1

2 idea的配置
在这里插入图片描述
1
登陆码云,然后将私人令牌配置到idea中
1
3 项目

git init
cd .git
vi config
# 下面是config的内容
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
        url = https://gitee的用户名:gitee的密码@gitee.com/hellott/test.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

push to origin/master was rejected错误解决方案,执行下面的命令,然后再push

git pull
git pull origin master
git pull origin master --allow-unrelated-histories
  • 1
  • 2
  • 3

下图跟git无关,记录一下如何将文件夹变成工程中可以编译的路径

在这里插入图片描述

4 mybatis
mybatis-generator-core,我在之前eclipse的基础上mybatis generator dao扩展,做了一次迁移
接着按照idea的方式进行配置使用,在1.3.7的版本增加了一个小版本1.3.7.1,这里综合了几家的版本,做了一下整合成为我喜欢的方式,IDEA 中使用MyBatis-generator 自动生成MyBatis代码IDEA使用mybatis-generator,这里mysql的驱动不用com.mysql.jdbc.Driver,已经过时了,而是com.mysql.cj.jdbc.Driver

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
    <classPathEntry
            location="/Applications/apps/apache-maven-3.5.4/repo/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar"/>
    <context id="mysqlTables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="mergeable" value="false"></property>
            <property name="suppressDate" value="true"/>
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--数据库链接URL,用户名、密码 -->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/fay" userId="fay"
                        password="Fay123456">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!-- 生成模型的包名和位置-->
        <javaModelGenerator targetPackage="com.dzmsoft.bazi.db.pojo" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <!-- 生成映射文件的包名和位置-->
        <sqlMapGenerator targetPackage="com.dzmsoft.bazi.db.mapping" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!-- 生成mapper位置-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.dzmsoft.bazi.db.dao" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>

        <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
        <!--<table tableName="bazi_info" domainObjectName="BaziInfo" enableCountByExample="false" enableUpdateByExample="false"-->
               <!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
        <table schema="" tableName="bazi_info"></table>

    </context>
</generatorConfiguration>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

按照IDEA 中使用MyBatis-generator 自动生成MyBatis代码,做一下配置.
想看详细的日志,则配置为mybatis-generator:generate -e查看详细日志
1
POM.xml中的配置,这里使用了自定义的版本1.3.7.1

<?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">
    <parent>
        <artifactId>fay</artifactId>
        <groupId>com.dzmsoft</groupId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>fay-db</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.miemiedev</groupId>
            <artifactId>mybatis-paginator</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.7</version>
                <configuration>
                    <!-- 在控制台打印执行日志 -->
                    <verbose>true</verbose>
                    <!-- 重复生成时会覆盖之前的文件-->
                    <overwrite>true</overwrite>
                    <configurationFile>src/test/resources/generatorConfig.xml</configurationFile>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.13</version>
                    </dependency>
                    <dependency>
                        <groupId>org.mybatis.generator</groupId>
                        <artifactId>mybatis-generator-core</artifactId>
                        <version>1.3.7.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>Generate MyBatis Artifacts</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

我从mac的环境,切换了一台windows的电脑,编译出现下面的问题,从Apache Maven 3.6.3替换原来的3.1.1

[INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (enforce-java) @ mybatis-generator-core ---
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Rule 2: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:


Detected Maven Version: 3.1.1 is not in the allowed range [3.2.5,).
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-java) on project mybatis-generator-core: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

结果提示新的问题,按照maven jdk 8 Error while generating Javadoc 或者 Error while creating archive

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.1:jar (default) on project mybatis-generator-core: MavenReportException: Error while generating Javadoc: 
[ERROR] Exit code: 1 - javadoc: ���� - û�г����org.mybatis.generator.ant��Դ�ļ�
  • 1
  • 2

将下面的代码注释掉

<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-javadoc-plugin</artifactId>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <phase>prepare-package</phase>-->
<!--                        <goals>-->
<!--                            <goal>jar</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <additionalJOption>-Xdoclint:none</additionalJOption>-->
<!--                        </configuration>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

随着年龄的增大,在java、python、scala、golang这几种语言切换还是没有年轻人那么多干劲。索性把一些问题记录下来得了,面得总是靠搜索。
5 maven的问题
5.1 一些包下载不下来

Could not transfer artifact org.springframework.boot:spring-boot-dependencies:pom:2.1.5.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.1.5.RELEASE/spring-boot-dependencies-2.1.5.RELEASE.pom. Return code is: 501 , ReasonPhrase:HTTPS Required.
  • 1

在maven在settings中配置阿里云的mirror

<mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>       
    </mirror>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

配置后好后,maven clean、compile通过了。
5.2 编译的依赖包的问题
出现下面的问题并不影响jar的生成
1

Some problems were encountered while building the effective model for com.github.hongwen1993:fast-drools-spring-boot-starter:jar:8.0.7
'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId' for org.quartz-scheduler:quartz:jar with value '*' does not match a valid id pattern. @ org.springframework.boot:spring-boot-dependencies:2.1.5.RELEASE, D:\repository\org\springframework\boot\spring-boot-dependencies\2.1.5.RELEASE\spring-boot-dependencies-2.1.5.RELEASE.pom, line 2608, column 25
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.
  • 1
  • 2
  • 3
  • 4

造成这个问题,是因为我本地的maven版本太低了,将maven切换到高的版本就可以了。
1

5.3 setting格式问题
解决方案去掉相应的空格、换行、tab等符号。

expected START_TAG or END_TAG not TEXT (position: TEXT seen ..
  • 1

5.4 language level自动变化
出现这个问题,只需要在pom.xml中配置即可

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

1
5.5 spring的autowire异常
service中引用mapper,提示 could not autowire
1

其他的待续…

在下面的工作目录下,iml文件内容不正确,导致编译不通过
2
5.6 项目启动报错
workspace.xml中找到PropertiesComponent模块,添加<property name="dynamic.classpath" value="true" />,问题解决

11:14	Error running 'VoucherServerApplication': Command line is too long. Shorten command line for VoucherServerApplication or also for Spring Boot default configuration?

  • 1
  • 2

2
5.7 Method breakpoints may dramatically slow down debugging
设置了断点太多,导致服务启动非常慢,开始还以为是程序有问题,看到idea的这个提示,才知道是断点设置太多了,去掉即可。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/688469
推荐阅读
相关标签
  

闽ICP备14008679号