先看错误
我用的是1.2.11版本 在maven项目中要引入druid依赖,会发现这两个会报红,然后运行的时候,会说找不到文件
出现 Could not find artifact com.sun:tools:jar:1.8 at specified path 或者 Cannot resolve com.sun:jconsole:1.8
1.jdk版本1.8以上
如果项目用的JDK就是java11+,且本地JDK version同样是11,那么你需要进行添加依赖了,依赖如下:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>jconsole</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/jconsole.jar</systemPath>
</dependency>
然后去网上把jconsole.jar与tools.jar 下载下来,添加到你的jdk的lib文件夹下,之后就可用了
2..jdk版本1.8
首先,你要打开你的maven仓库找到
然后打开这个文件,然后拉到最下面,然后把关于tools与jconsole的依赖换成
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>jconsole</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/jconsole.jar</systemPath>
</dependency>
把配置改成如下图这样
保存退出
之后可用看到
之后就可用了
但是如果你要用mybatis自动配置文件,会发现BaseResultMap的值重复
就要在配置文件中加上一句
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
如果你用的是<generatorConfiguration>标签来配置,就要把上述语句放在<context>标签下面
不然会报错,说你格式不对