springboot & dubbo

spring-boot-maven-plugin

1
2
3
4
5
6
7
8
9
10
11
12
<properties>
<start-class>com.cifm.ds.account.AccountApp</start-class>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
  1. 打包可执行的jar包
  2. 不要放在不是运行jar的pom.xml文件中,否则出现👇错误

Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.0.M1:repackage failed: Unable to find main class

dubbo的序列化与spring

1
2
3
4
5
# dubbo的序列化的序列化有问题
# 主要是类型的定义,比如int类型,序列化后值都为0
# 还有其他的未知原因
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

自定义spring boot jpa Repository

1
2
3
4
5
6
@NoRepositoryBean
public interface BaseRepository<T extends Serializable, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {
}

# 此处很重要,不加,spring boot jpa 会把BaseRepository定义的方法当做T的属性去解析
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class)

spring boot test

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
public interface AutoTest {
}
public interface SelfTest {
}

@Category(AutoTest.class)
public class OutTest {
@Test
public void out1() {
log.info("hello");
}
}

@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApp.class)
@Category(SelfTest.class)
public class AccountTest {
}

/**
* 执行此测试类,只会执行OutTest的测试类,AccountTest的测试类不会执行
*/
@RunWith(Categories.class)
@IncludeCategory(AutoTest.class)
@ExcludeCategory(SelfTest.class)
@SuiteClasses({OutTest.class, AccountTest.class})
public class AccountTestSuite {
}

mvn 排除部分测试类不进入自动测试

1
2
3
4
5
6
7
8
9
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>com/lendo/test/account/self/**</exclude>
</excludes>
</configuration>
</plugin>