我在私有网络(私有服务器,不是 aws 或 google cloud)上有一个 kubernetes 集群,并且我创建了一个能够访问的服务,但是,我需要能够从集群外部访问,为此我创建了一个 Ingress并在集群中添加了 ingress-nginx。
这是我在多次尝试后使用的 YAML:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: demo-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: k8s.local
http:
paths:
- path: /
backend:
serviceName: nginx
servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: ClusterIP
selector:
name: nginx
ports:
- port: 80
targetPort: 80
protocol: TCP
# selector:
# app: nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
template:
metadata:
labels:
app: …Run Code Online (Sandbox Code Playgroud) 我正在使用 dto 进行一些字段验证测试,并在 Spring boot api 上使用 @NotEmpty 注释 LocalDate 变量,但是,我收到此错误:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.time.LocalDate'. Check configuration for 'dateBirth'
注释库是 javax.validation.constraints.NotEmpty,但曾尝试使用 javax.validation.constraints.NotEmpty,因此注释被标记为已弃用。
变量的声明:
@NotEmpty(message = "Campo Data de Nascimento é obrigatório")
private LocalDate dateBirth;
Run Code Online (Sandbox Code Playgroud)
是否有必要在 pom.xml 或其他东西中添加一些依赖项?
我正在尝试在具有H2数据库的Spring Boot api上运行测试中的测试,但是,当尝试运行测试时,系统使用的是主要资源中的application.properties而不是测试。我尝试将文件命名为application-test.properties,并@ActiveProfiles("test")在测试类中使用批注,但这不起作用(先将测试放入main / resource中,然后再放入test / resouce中)现在我不知道该尝试什么。
我的main / resource / apllication.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/chamados
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
Run Code Online (Sandbox Code Playgroud)
我的测试/资源/ application.properties:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=false
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
Run Code Online (Sandbox Code Playgroud)
我刚刚运行的测试类:
@RunWith(SpringRunner.class)
@SpringBootTest
public class BackEndApplicationTests {
@Test
public void contextLoads() {
}
}
Run Code Online (Sandbox Code Playgroud)
我的pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jwt.version>0.9.1</jwt.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency> …Run Code Online (Sandbox Code Playgroud)