Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何导入pom.xml里面 #4

Closed
soulmz opened this issue Jun 5, 2017 · 10 comments
Closed

如何导入pom.xml里面 #4

soulmz opened this issue Jun 5, 2017 · 10 comments

Comments

@soulmz
Copy link

soulmz commented Jun 5, 2017

No description provided.

@soulmz
Copy link
Author

soulmz commented Jun 5, 2017

`

  <plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>${dev.plugin.mybatis-generator}</version>
    <configuration>
      <configurationFile>${basedir}/src/main/resources/mybatis-generator-config.xml</configurationFile>
      <overwrite>true</overwrite>
      <verbose>true</verbose>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${dev.lib.mysql-connector}</version>
      </dependency>
      <!-- 增强mybatis-generator 插件 -->
      <dependency>
        <groupId>com.itfsw</groupId>
        <artifactId>mybatis-generator-plugin</artifactId>
        <version>1.0.9</version>
      </dependency>
    </dependencies>
  </plugin>

`
已经导入到Mybatis 插件了,在mybatis-generator-config.xml文件里报错,类总是找不到。

@itfsw
Copy link
Owner

itfsw commented Jun 5, 2017

请问是哪个类找不到呢?或者你在maven本地仓储看下这个依赖是否已经下载成功呢?

@soulmz
Copy link
Author

soulmz commented Jun 6, 2017

导入了,lib 依赖也有了。
1

2

@soulmz
Copy link
Author

soulmz commented Jun 6, 2017

@itfsw 是我导入姿势不对吗?

@itfsw
Copy link
Owner

itfsw commented Jun 6, 2017

你好我参照你的配置,然后从中央库重新更新了依赖,重新运行是没有问题的啊:

<!-- mybatis-generator 自动代码插件 -->
<plugin>
	<groupId>org.mybatis.generator</groupId>
	<artifactId>mybatis-generator-maven-plugin</artifactId>
	<version>1.3.5</version>
	<configuration>
		<!-- 配置文件 -->
		<configurationFile>src/main/resources/excludes/mybatis-generator.xml</configurationFile>
		<!-- 允许移动和修改 -->
		<verbose>true</verbose>
		<overwrite>true</overwrite>
	</configuration>
	<dependencies>
		<!-- jdbc 依赖 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.40</version>
		</dependency>
		<dependency>
			<groupId>com.itfsw</groupId>
			<artifactId>mybatis-generator-plugin</artifactId>
			<version>1.0.9</version>
		</dependency>
	</dependencies>
</plugin>
<!--导入属性配置 -->
<context id="test" targetRuntime="MyBatis3">
    <!-- 插件 -->
    <!-- Table 前缀插件 -->
    <plugin type="com.itfsw.mybatis.generator.plugins.TableSuffixPlugin">
        <property name="suffix" value="DB1"/>
    </plugin>
    <!-- ......... -->
</context>

qq 20170606095242
qq 20170606095537

@soulmz
Copy link
Author

soulmz commented Jun 6, 2017

问题找到了,在源码看到了

/**
 * ---------------------------------------------------------------------------
 * 基础plugin
 * ---------------------------------------------------------------------------
 * @author: hewei
 * @time:2017/4/28 13:57
 * ---------------------------------------------------------------------------
 */
public class BasePlugin extends PluginAdapter {
    protected static final Logger logger = LoggerFactory.getLogger(BasePlugin.class); // 日志
    protected IWCommentGenerator commentGenerator = new IWCommentGenerator();  // 注释工具

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean validate(List<String> warnings) {
        // 插件使用前提是targetRuntime为MyBatis3
        if (StringUtility.stringHasValue(getContext().getTargetRuntime()) && "MyBatis3".equalsIgnoreCase(getContext().getTargetRuntime()) == false) {
            logger.warn("itfsw:插件" + this.getClass().getTypeName() + "要求运行targetRuntime必须为MyBatis3!");
            return false;
        }

        return true;
    }
}

必须使用mybatis3
不支持 MyBatis3Simple

另外,可以增加个去掉前缀吗? 某些表的前缀去除
例如:T_order,T_order_item -> order , order_item

@soulmz
Copy link
Author

soulmz commented Jun 6, 2017

@itfsw 插件在pom.xml 会提示找不到类。可能是我IDEA 问题。
把TargetRuntime 改成Mybatis3 ,效果就出来了

@itfsw
Copy link
Owner

itfsw commented Jun 6, 2017

好的,后期会逐渐完善插件,感谢你的建议。

@itfsw itfsw closed this as completed Jun 6, 2017
@itfsw
Copy link
Owner

itfsw commented Jun 7, 2017

Table重命名插件已实现你所需要的功能,请测试使用,感谢你的建议Mybatis Generator Plugin Realease 1.0.10

@soulmz
Copy link
Author

soulmz commented Jun 8, 2017

@itfsw 问一个问题,能生成中文注释么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants