我想利用 Sendgrid 模板版本来支持多语言支持。
根据 Sendgrid文档:
一个模板一次只能有一个活动版本。如果您创建了一个包含不同 HTML 的新版本,您希望客户开始接收该版本,则需要将该版本设为“活动”。
因此,例如我有 2 个版本的模板:English(active)和Russian。因此,如果我想用俄语版本发送电子邮件,我需要在发送电子邮件之前激活俄语模板版本。
但我担心的是:如果我需要同时发送俄文和英文版本的电子邮件怎么办?Sendgrind 能否为 2 个同时请求提供合适的版本?
我在 Spring Boot 应用程序中使用schema.sql文件到CREATE/DROP表,它工作正常。
但是当我添加了更改表的程序时:
DELIMITER $$
CREATE PROCEDURE Alter_Table()
BEGIN
IF NOT EXISTS( SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'test_table'
AND table_schema = 'test'
AND column_name = 'cc_test_id') THEN
alter table test_table add cc_test_id VARCHAR(128) NOT NULL;
END IF;
END $$
call Alter_Table;
Run Code Online (Sandbox Code Playgroud)
我收到了:
Run Code Online (Sandbox Code Playgroud)com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException exception.
但是,在 MySQL 工作台中执行此过程并成功完成。
那么,有人应该知道这个问题的原因是什么,让我知道吗?
我为我的春季启动应用程序创建了自定义登录表单.在我的表单集成测试中,我想检查收到的cookie是否包含JSESSIONID和XSRF-TOKEN.
但是,我只收到了XSRF-TOKEN.
这是我的测试:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
public class UserIT {
@Autowired
private WebApplicationContext context;
@Autowired
private FilterChainProxy springSecurityFilterChain;
@Value("${local.server.port}")
private Integer port;
private MockMvc mockMvc;
@Before
public void setup() {
mockMvc =
MockMvcBuilders.webAppContextSetup(context).addFilters(springSecurityFilterChain)
.build();
}
@Test
public void getUserInfoTest() throws Exception {
disableSslVerification();
MvcResult result =
mockMvc.perform(formLogin("/login").user("roy").password("spring")).andExpect(authenticated())
.andReturn();
Cookie sessionId = result.getResponse().getCookie("JSESSIONID");
Cookie token = result.getResponse().getCookie("XSRF-TOKEN");
}
Run Code Online (Sandbox Code Playgroud)
安全配置:
@Override
public void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
//.httpBasic()
//.and() …Run Code Online (Sandbox Code Playgroud) 我想为存储在Redis中的密钥设置一个ttl,我已按以下方式完成:
@Component
public class RedisBetgeniusMarketService implements BetgeniusMarketService {
private static final int DEFAULT_EVENTS_LIFE_TIME = 240;
@Value("${redis.events.lifetime}")
private long eventsLifeTime = DEFAULT_EVENTS_LIFE_TIME;
@Autowired
private RedisTemplate<String, Market> marketTemplate;
@Override
public Market findOne(Integer fixtureId, Long marketId) {
String key = buildKey(fixtureId, marketId);
return marketTemplate.boundValueOps(key).get();
}
@Override
public void save(Integer fixtureId, Market market) {
String key = buildKey(fixtureId, market.getId());
BoundValueOperations<String, Market> boundValueOperations = marketTemplate.boundValueOps(key);
boundValueOperations.expire(eventsLifeTime, TimeUnit.MINUTES);
boundValueOperations.set(market);
}
private String buildKey(Integer fixtureId, Long marketId) {
return "market:" + fixtureId + ":" + marketId;
} …Run Code Online (Sandbox Code Playgroud) 我在机器上运行应用程序JUnit5的集成测试(使用)时遇到问题。我的测试依赖于两个容器,我使用Testcontainers java 库定义:和。版本是.micronautWindows 10 ProRabbitMQMS SQL serverDockerv19.03.13
运行集成测试后,我收到以下异常:
\n[WARN ][DESKTOP-PBCHP60] [testcontainers.utility.TestcontainersConfiguration] \xe2\x80\x93 Attempted to read Testcontainers configuration file at file:/$HOME.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: $HOME\\.testcontainers.properties (The system cannot find the file specified)\nRun Code Online (Sandbox Code Playgroud)\n不过,从机器运行测试时我没有收到此异常macOS。我的假设是它是Windows特定的。
谁能告诉我如何解决它?我应该自己创建所需的文件吗?或者也许有一种方法可以在运行 IT 期间跳过读取此文件的步骤?
\n当我尝试让用户使用存储库接口时,我收到以下异常"org.springframework.dao.InvalidDataAccessApiUsageException:在结果元组中找不到别名!确保您的查询定义了别名!;嵌套异常是java.lang.IllegalStateException:找不到别名在结果元组中!确保您的查询定义了别名!"
库:
@Repository
public interface UserRelationshipRepository
extends JpaRepository<UserRelationship, Long>, QueryDslPredicateExecutor<UserRelationship> {
@Query(value = "SELECT ur.id.toUser FROM UserRelationship ur WHERE ur.fromUser = :fromUser AND ur.relationshipTypeId = 1")
Set<User> findUserFriends(@Param("fromUser") User fromUser);
}
Run Code Online (Sandbox Code Playgroud)
实体:
@Entity
@NamedEntityGraph(name = "graph.User", attributeNodes = {})
@Table(name = "users")
public class User extends BaseEntity implements UserDetails {
private static final long serialVersionUID = 8884184875433252086L;
@Id
@SequenceGenerator(name = "users_id_seq", sequenceName = "users_id_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "users_id_seq")
private Long id;
@Column(name = "first_name") …Run Code Online (Sandbox Code Playgroud) 我正进入(状态
Caused by: org.opensaml.common.SAMLException: Unsupported request
at org.springframework.security.saml.processor.SAMLProcessorImpl.getBinding(SAMLProcessorImpl.java:265) ~[spring-security-saml2-core-1.0.3.RELEASE.jar:1.0.3.RELEASE]
at org.springframework.security.saml.processor.SAMLProcessorImpl.retrieveMessage(SAMLProcessorImpl.java:172) ~[spring-security-saml2-core-1.0.3.RELEASE.jar:1.0.3.RELEASE]
at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:80) ~[spring-security-saml2-core-1.0.3.RELEASE.jar:1.0.3.RELEASE]
... 62 more exception
Run Code Online (Sandbox Code Playgroud)
在测试 SP 和客户端 IdP 之间的 SSO 时。
根据org.springframework.security.saml.processor.SAMLProcessorImpl#getBinding(org.opensaml.ws.transport.InTransport)方法源代码,当找不到合适的消息解码器时会抛出此异常。
在我的安全上下文中,我定义了下一个绑定:
<!-- Class loading incoming SAML messages from httpRequest stream -->
<bean id="processor" class="org.springframework.security.saml.processor.SAMLProcessorImpl">
<constructor-arg>
<list>
<ref bean="redirectBinding"/>
<ref bean="postBinding"/>
<ref bean="artifactBinding"/>
<ref bean="soapBinding"/>
<ref bean="paosBinding"/>
</list>
</constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
谁能帮助我理解为什么会发生这种情况?
更新:
如果我使用http://idp.ssocircle.com作为 IdP,一切正常,只有当我尝试与不同的 IdP 链接时才会出现问题。
这是调试日志:
2019-03-04 16:46:42.315 DEBUG [211 default task-43][ExceptionTranslationFilter] Calling Authentication entry point.
2019-03-04 16:46:42.315 …Run Code Online (Sandbox Code Playgroud) 我的 ES 节点之一因java.lang.OutOfMemoryError: Java heap space错误而失败。这是日志中的完整堆栈跟踪:
[2020-09-18T04:25:04,215][WARN ][o.e.a.b.TransportShardBulkAction] [search1] [[my_index_4][0]] failed to perform indices:data/write/bulk[s] on replica [my_index_4][0], node[cm_76wfGRFm9nbPR1mJxTQ], [R], s[STARTED], a[id=BUpviwHxQK2qC3GrELC2Hw]
org.elasticsearch.transport.NodeDisconnectedException: [search3][X.X.X.179:9300][indices:data/write/bulk[s][r]] disconnected
[2020-09-18T04:25:04,215][WARN ][o.e.c.a.s.ShardStateAction] [search1] [my_index_4][0] received shard failed for shard id [[my_index_4][0]], allocation id [BUpviwHxQK2qC3GrELC2Hw], primary term [2], message [failed to perform indices:data/write/bulk[s] on replica [my_index_4][0], node[cm_76wfGRFm9nbPR1mJxTQ], [R], s[STARTED], a[id=BUpviwHxQK2qC3GrELC2Hw]], failure [NodeDisconnectedException[[search3][X.X.X.179:9300][indices:data/write/bulk[s][r]] disconnected]]
org.elasticsearch.transport.NodeDisconnectedException: [search3][X.X.X.179:9300][indices:data/write/bulk[s][r]] disconnected
[2020-09-18T04:25:04,215][DEBUG][o.e.a.a.c.n.i.TransportNodesInfoAction] [search1] failed to execute on node [cm_76wfGRFm9nbPR1mJxTQ]
org.elasticsearch.transport.NodeDisconnectedException: [search3][X.X.X.179:9300][cluster:monitor/nodes/info[n]] disconnected
[2020-09-18T04:25:04,219][INFO ][o.e.c.r.a.AllocationService] [search1] Cluster health status changed from …Run Code Online (Sandbox Code Playgroud) 我使用这篇文章为我的一个实体实现了带有 spring-data-jpa 的批量插入。我正在使用 MS SQL 数据库。
我将主键生成策略从更改GenerationType.IDENTITY为GenerationType.SEQUENCE:
@Entity
@Table(name = "Answers")
public class AnswerDMO implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private long id;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "answer_new_generator")
@SequenceGenerator(name = "answer_new_generator", sequenceName = "answer_new_sequence", allocationSize = 15)
@Column(name = "Id", unique = true, nullable = false)
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
Run Code Online (Sandbox Code Playgroud)
服务方法通过调用来保存应答实体列表<S extends T> List<S> save(Iterable<S> …
我有一个以独立模式运行的 Keycloak 身份验证服务器。我的要求是用户应该能够使用他们的 Google 帐户登录,因此我按照 Keycloak文档中的步骤添加了 Google IdP 。新用户使用其 Google 帐户成功登录后,应创建新帐户并将其存储在 Postgresql 数据库中。为了实现这一点,我按照此示例创建了自定义用户存储提供程序。该示例仅涵盖获取用户详细信息部分。为了支持添加新用户,我实现addUser了org.keycloak.storage.user.UserRegistrationProvider接口方法:
@Override
public UserModel addUser(RealmModel realmModel, String s) {
logger.info("create user with username: " + s);
UserEntity userEntity = new UserEntity(s, null, s, s);
em.persist(userEntity);
em.flush();
return new UserAdapter(kcSession, realmModel, model, userEntity);
}
Run Code Online (Sandbox Code Playgroud)
在测试流程时,Keycloak 在执行getUserById自定义提供程序方法时抛出异常。根据日志,此方法被多次调用。该方法如下所示:
@Override
public UserModel getUserById(String id, RealmModel realm) {
logger.info("getUserById: " + id);
String persistenceId = StorageId.externalId(id);
System.out.println("!!! :" + StorageId.keycloakId(model, id));
System.out.println("!!! " …Run Code Online (Sandbox Code Playgroud)