假设我有允许输入的组合框。我想限制输入,例如,用户只能输入10个字符。我该怎么做?谢谢。
让我们想象一下我跟随mojo:
@Mojo(name = "some-goal")
public class MyMojo {
@Parameter(required = true)
protected ComplexObject param;
/*...*/
}
Run Code Online (Sandbox Code Playgroud)
另外我在pom中有插件的描述符:
<plugin>
<!-- here artifact description -->
<executions>
<execution>
<phase>...</phase>
<goals><goal>some-goal</goal></goals>
<configuration>
<param>...</param>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
为了测试这个插件我使用maven-plugin-testing-harness
我的测试代码是:
@Test
public void test() throws Exception {
File pom = getFile("mix/pom.xml");
MyMojo plugin = (MyMojo) rule.lookupMojo("some-goal", pom);
/*....*/
Run Code Online (Sandbox Code Playgroud)
}
规则是:
@Rule
public MojoRule rule = new MojoRule() {
@Override
protected void before() throws Throwable {
}
@Override
protected void after() {
}
};
Run Code Online (Sandbox Code Playgroud)
但是当我运行测试时,它会因异常而失败: …
我在实体中有以下ID说明:
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
Run Code Online (Sandbox Code Playgroud)
以下是用于生成此ID的Liquibase指令:
<column name="id" autoIncrement="true" type="INT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_entity"/>
</column>
Run Code Online (Sandbox Code Playgroud)
我也有liquibase脚本,可以将预定义值插入该表,例如
<insert tableName="entityTable" schemaName="public">
<column name="id">1</column>
<!- other fields-->
</insert>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用Jpa存储库插入没有ID的新记录时出现了问题。我收到类似“重复ID”的错误消息。因此,我知道jpa(hibernate)不使用postgresql序列来获取新的id值。而且我不想在实体的ID描述中包含序列名称。我希望Postgresql可以解决这种情况。而且我不会使用“ hibernate_sequence”。因此,任何想法我都可以解决此问题。谢谢。