我有一个带有spring数据,jpa和hibernate的spring mvc项目.我有一个多语言数据库.我设计了我的数据库和实体.我正在寻找一种按语言查询表格的最佳实践.我是否必须编写自定义jpa查询,或者是否有通用的方法来查询我的表.
如果我在db或实体设计上有错误,请警告我.
数据库:
CREATE TABLE translation (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id));
CREATE TABLE translation_text (
translation_id BIGINT UNSIGNED NOT NULL,
lang VARCHAR(2),
text VARCHAR(1000));
ALTER TABLE translation_text
ADD FOREIGN KEY (translation_id)
REFERENCES translation(id);
CREATE TABLE category (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
category_name BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (id));
ALTER TABLE category
ADD FOREIGN KEY (category_name)
REFERENCES translation(id);
Run Code Online (Sandbox Code Playgroud)
LocalizedString实体:
@Embeddable
public class LocalizedString {
private String lang;
private String text;
//Constructors and …Run Code Online (Sandbox Code Playgroud) 我有一个Spring rest服务,我想将它用于经过身份验证且未经过身份验证的用户.我想从SecurityContextHolder.getContext().getAuthentication()用户身份验证中获取用户信息.
.antMatchers("/app/rest/question/useroperation/list/**").permitAll()
在下面的ouath2配置中使用,那么我可以获得经过身份验证的用户的用户信息,但是对于未经过身份验证的用户,我会收到401错误..antMatchers("/app/rest/question/useroperation/list/**").permitAll()
忽略了WebSecurity中的url
,那么所有用户都可以调用该服务,但是我无法从SecurityContext获取用户信息.web.ignoring()..antMatchers("/app/rest/question/useroperation/list/**")SecurityConfiguration如果用户登录,如何配置我的spring安全性来为经过身份验证且未经过身份验证的用户调用URL并从SecurityContext获取用户信息.
@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Inject
private Http401UnauthorizedEntryPoint authenticationEntryPoint;
@Inject
private AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler;
@Override
public void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint)
.and()
.logout()
.logoutUrl("/app/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler)
.and()
.csrf()
.requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/authorize"))
.disable()
.headers()
.frameOptions().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/views/**").permitAll()
.antMatchers("/app/rest/authenticate").permitAll()
.antMatchers("/app/rest/register").permitAll()
.antMatchers("/app/rest/question/useroperation/list/**").permitAll()
.antMatchers("/app/rest/question/useroperation/comment/**").authenticated()
.antMatchers("/app/rest/question/useroperation/answer/**").authenticated()
.antMatchers("/app/rest/question/definition/**").hasAnyAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/app/rest/logs/**").hasAnyAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/app/**").authenticated()
.antMatchers("/websocket/tracker").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/websocket/**").permitAll()
.antMatchers("/metrics/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/health/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN) …Run Code Online (Sandbox Code Playgroud) 我正试图通过你来实现jhipster项目.但是当我运行它时,会发生一个奇怪的错误:The package karma does not satisfy its siblings' peerDependencies requirements!
我完全卸载了nodejs并再次安装它,但仍然是同样的错误.当我搜索有一些像这样或这样的解决方案建议.
我有64位win7,节点-v v0.10.26 npm -v 1.4.3
error peerinvalid The package karma does not satisfy its siblings' peerDependencies requirements!
error peerinvalid Peer karma-script-launcher@0.1.0 wants karma@>=0.9
error peerinvalid Peer karma-chrome-launcher@0.1.2 wants karma@>=0.9.3
error peerinvalid Peer karma-html2js-preprocessor@0.1.0 wants karma@>=0.9
error peerinvalid Peer karma-jasmine@0.1.5 wants karma@>=0.9
error peerinvalid Peer karma-requirejs@0.2.1 wants karma@>=0.9
error peerinvalid Peer karma-phantomjs-launcher@0.1.2 wants karma@>=0.9
error peerinvalid Peer grunt-karma@0.7.3 wants karma@~0.12.0
error System Windows_NT 6.1.7601
error …Run Code Online (Sandbox Code Playgroud) 我希望Ingress将特定子域重定向到一个后端,将所有其他子域重定向到另一后端。基本上,我想定义如下规则:
如果是子域,
foo.bar.com则转到s1,对于所有其他子域,请转到s2
当我按照Ingress规范中的定义定义规则时,在部署时会遇到此异常:
Error: UPGRADE FAILED: cannot re-use a name that is still in use
Run Code Online (Sandbox Code Playgroud)
但是,当我更改*.bar.com为demo.bar.com它时,它会起作用。
这是我的Ingress资源规范:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test
spec:
rules:
- host: foo.bar.com
http:
paths:
- backend:
serviceName: s1
servicePort: 80
- host: *.bar.com
http:
paths:
- backend:
serviceName: s2
servicePort: 80
Run Code Online (Sandbox Code Playgroud)
任何人都知道是否可能吗?
我有一个Spring 4的Spring MVC项目.我的服务器是tomcat 7.我正在尝试创建一个404页面,我尝试了很多东西,但我做不到.
我错过了什么?
这是WebAppContext:
@Configuration
@ComponentScan(basePackages = {
"com.***"
})
@EnableWebMvc
public class WebAppContext extends WebMvcConfigurerAdapter {
private static final String VIEW_RESOLVER_PREFIX = "/WEB-INF/pages/";
private static final String VIEW_RESOLVER_SUFFIX = ".jsp";
@Autowired
private EventLogService eventLogService;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public SimpleMappingExceptionResolver exceptionResolver() {
SimpleMappingExceptionResolver exceptionResolver = new SimpleMappingExceptionResolver();
Properties exceptionMappings = new Properties();
exceptionMappings.put("org.springframework.security.web.authentication.rememberme.CookieTheftException", "user/login?error=sessionExpired");
exceptionMappings.put("java.lang.RuntimeException", "error/error");
exceptionMappings.put("java.lang.Exception", "error/error");
exceptionResolver.setExceptionMappings(exceptionMappings);
Properties statusCodes = new Properties(); …Run Code Online (Sandbox Code Playgroud) 在vert.x中,如果标头中不存在“ X-Requested-With”标头,我想拒绝请求。我要这样做是为了保护CSRF?我找不到一个很好的文件。有人有主意吗?
我有一个折线图.x轴有日期,但它们不是正常分布的(午餐或周末没有数据),但我想按顺序显示它们.示例数据和我的示例图表如下,我不希望我的图表显示没有数据的时间的直线,它应该从前一个日期继续.
我x = d3.time.scale().range([0, width])用来画x线.任何的想法?
x y
10:00:00 4
10:10:00 5
10:20:00 3
10:30:00 2
10:40:00 5
10:50:00 3
14:30:00 6
14:40:00 7
Run Code Online (Sandbox Code Playgroud)
java ×4
spring ×3
jhipster ×2
csrf ×1
d3.js ×1
hibernate ×1
javascript ×1
jpa ×1
karma-runner ×1
kubernetes ×1
npm ×1
servlet-3.0 ×1
spring-data ×1
spring-mvc ×1
traefik ×1
vert.x ×1
yeoman ×1