小编Mar*_*Man的帖子

如何在Packer中使用文件配置器的用户变量?

我有一个包装工json喜欢:

"builders": [{...}],
"provisioners": [
          {
                "type": "file",
                "source": "packer/myfile.json",
                "destination": "/tmp/myfile.json"
           }
  ],
"variables": {
        "myvariablename": "value"
 }
Run Code Online (Sandbox Code Playgroud)

和myfile.json是:

{
   "var" : "{{ user `myvariablename`}}"
}
Run Code Online (Sandbox Code Playgroud)

进入文件的变量确实被替换,在文件可用于此处的唯一选项后,是否使用shell provisioner进行sed替换?

使用封隔器版本0.12.0

packer

8
推荐指数
2
解决办法
4453
查看次数

使用 MyBatis 和 MySql 以编程方式创建表

我想创建一种方法来动态创建表,只需将表名作为变量传递即可。我已经定义了我的 xml 映射器

<mapper namespace="com.mappers.TableCreatorMapper">
    <cache />
    <insert id="createNewTableIfNotExists" parameterType="String" > 
        CREATE TABLE IF NOT EXISTS #{tableName} 
        (
        `ID` varchar(20) NOT NULL,
        PRIMARY KEY (`ID`)
        ) 
        ENGINE=InnoDB
    </insert>
</mapper>
Run Code Online (Sandbox Code Playgroud)

我的 Java 接口映射器很简单:

public interface TableCreatorMapper {
     public void createNewTableIfNotExists(String tableName);
}
Run Code Online (Sandbox Code Playgroud)

但是当我调用我的界面时

tableCreatorMapper.createNewTableIfNotExists("test");
Run Code Online (Sandbox Code Playgroud)

我得到以下异常:

org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test' 
        (
        `ID` varchar(20) …
Run Code Online (Sandbox Code Playgroud)

java mysql database mybatis spring-mybatis

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

database ×1

java ×1

mybatis ×1

mysql ×1

packer ×1

spring-mybatis ×1