我正面临一个问题
命令"bower install"退出代码9009
同时使用实体框架发布ASP.NET核心MVC应用程序.我正在使用VS-2017.
我在你的node.js全球下载门户网站上收到了很多建议,但由于我对这个系统很新,我不知道该怎么做.或者,如果有任何其他解决方案,请告诉我.
尝试配置 JWT 配置。看来 JWT 已被弃用。OAuth2ResourceServerConfigurer::jwt我现在该如何使用?
我的代码:
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
http.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
//http.formLogin(withDefaults());
http.httpBasic(Customizer.withDefaults());
http.csrf(csrf -> csrf.disable());
http.headers(headers -> headers.frameOptions(frameOptionsConfig -> frameOptionsConfig.sameOrigin()));
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
return http.build();
}
Run Code Online (Sandbox Code Playgroud)
此外,在 Spring Security 6.0 中,antMatchers()以及其他用于保护请求的配置方法(即mvcMatchers()和regexMatchers())已从 API 中删除。
我在Java,Answer和Collaborator中有2个POJO类,处于多对多关系中.
class Answer {
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "ANSWERS_COLLABORATORS", joinColumns = { @JoinColumn(name = "aid") }, inverseJoinColumns = { @JoinColumn(name = "cid") })
private Set<Collaborator> collaborators = new HashSet<Collaborator>(0);
}
Run Code Online (Sandbox Code Playgroud)
类Answer有一套Collaborator,但是Collaborator不保留一套Answer.我需要从Hibernate做的CriteriaQuery是找到id给出的答案的协作者.
我已经使用结果转换器在Hibernate Criteria(org.hibernate.Criteria)中完成了这个,但是在使用时我遇到了困难CriteriaQuery,因为我没有给出连接的答案列表.
我在Tomcat中部署了我的应用程序,应用程序路径是:
http://localhost:8080/myapp
Run Code Online (Sandbox Code Playgroud)
但我想限制我的用户看不到Tomcat主页,即如果他们输入:
http://localhost:8080
Run Code Online (Sandbox Code Playgroud)
主页不应该出现.我该怎么办?
我正在尝试在我的存储库中创建自定义deleteBy方法查询.似乎hibernate不是删除,而是制作一个select语句.
public interface ContactRepository extends JpaRepository<Contact, Integer> {
Integer deleteByEmailAddress(String emailAddress);
//and this one works
Contact findContactByName(String name);
}
Run Code Online (Sandbox Code Playgroud)
这是Hibernate试图做的事情:
Hibernate:选择contact0_.id为id1_2_,contact0_.emailAddress为> emailAdd2_2_,contact0_.name为name3_2_来自联系人contact0_ where> contact0_.emailAddress =?
我错过了什么?我是否必须进行特殊配置才能使删除工作?
我正在尝试在标题中插入一个子查询,就像在这个简单的SQL中一样:
SELECT id, name, (select count(*) from item) from item
Run Code Online (Sandbox Code Playgroud)
这显然只是一个模拟查询只是为了说明我的观点.(关键是获取查询返回的每个项目的最后一张发票.)
我试过这个:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> c = cb.createTupleQuery();
Root<Item> item= c.from(Item.class);
Subquery<Long> scount = c.subquery(Long.class);
Root<Item> sarticolo = scount.from(Item.class);
scount.select(cb.count(sitem));
c.multiselect(item.get("id"),item.get("nome"), scount);
Query q = em.createQuery(c);
q.setMaxResults(100);
List<Tuple> result = q.getResultList();
for(Tuple t: result){
System.out.println(t.get(0) + ", " + t.get(1) + ", " + t.get(2));
}
Run Code Online (Sandbox Code Playgroud)
但我只得到:
java.lang.IllegalStateException:子查询不能出现在select子句中
我怎样才能得到类似的结果?
我正在尝试使用Spring Security,我有一个用例,我想要保护不同的登录页面和不同的URL集.
这是我的配置:
@Configuration
@Order(1)
public static class ProviderSecurity extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.antMatchers("/admin/login").permitAll()
.antMatchers("/admin/**").access("hasRole('BASE_USER')")
.and()
.formLogin()
.loginPage("/admin/login").permitAll()
.defaultSuccessUrl("/admin/home")
.failureUrl("/admin/login?error=true").permitAll()
.usernameParameter("username")
.passwordParameter("password")
.and()
.csrf()
.and()
.exceptionHandling().accessDeniedPage("/Access_Denied");
}
}
@Configuration
@Order(2)
public static class ConsumerSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/consumer/login").permitAll()
.antMatchers("/consumer/**").access("hasRole('BASE_USER')")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/consumer/login").permitAll()
.defaultSuccessUrl("/consumer/home")
.failureUrl("/consumer/login?error=true").permitAll()
.usernameParameter("username")
.passwordParameter("password")
.and().csrf()
.and()
.exceptionHandling().accessDeniedPage("/Access_Denied");
}
}
Run Code Online (Sandbox Code Playgroud)
这些类是MultipleHttpSecurityConfig具有注释的另一个类的内部类@EnableWebSecurity.
安全性admin/**工作正常,但没有一个 …
我尝试将我的代码编译成没有错误,没有警告作为标准做法.但是,有一个恼人的警告,我知道如何处理.NET而不是Java.说我有这样的代码块:
try {
FileInputStream in = new FileInputStream(filename);
return new Scanner(in).useDelimiter("\\A").next();
} catch (FileNotFoundException ex) {
LOG.log(Level.SEVERE, "Unable to load file: {0}", filename);
return null;
}
Run Code Online (Sandbox Code Playgroud)
我得到一个警告,ex即没有使用变量.现在,我真的没有用ex,我不想ex,但我不知道该怎么做.在.NET中,我可以做到:
catch (FileNotFoundException)
Run Code Online (Sandbox Code Playgroud)
没有变量,它将编译并运行没有错误.
如何在Java中处理这种情况?我知道我可以创建一个局部变量并将其设置为ex,但这似乎是一个愚蠢和浪费的解决方法来修复一个不是真正需要的警告.
我创建了两个Web应用程序 - 客户端和服务应用程序.
当客户端和服务应用程序部署在同一个Tomcat实例中时,它们之间的交互很顺利.
但是当应用程序部署到单独的Tomcat实例(不同的机器)时,我在发送服务应用程序的请求时会收到以下错误.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 401
Run Code Online (Sandbox Code Playgroud)
我的客户端应用程序使用JQuery,HTML5和Bootstrap.
AJAX调用服务如下所示:
var auth = "Basic " + btoa({usname} + ":" + {password});
var service_url = {serviceAppDomainName}/services;
if($("#registrationForm").valid()){
var formData = JSON.stringify(getFormData(registrationForm));
$.ajax({
url: service_url+action,
dataType: 'json',
async: false,
type: 'POST',
headers:{
"Authorization":auth
},
contentType: 'application/json',
data: formData,
success: function(data){
//success code
}, …Run Code Online (Sandbox Code Playgroud) 我有一个私有的 GitLab 项目,其中包含用于构建和推送 Docker 映像的管道。因此我必须首先向 GitLab 的 Docker 注册表进行身份验证。
\n\n研究
\n\n我阅读了使用 GitLab CI/CD 对容器注册表进行身份验证:
\n\n\n有三种方法可以通过 GitLab CI/CD 对容器注册表进行身份验证,具体取决于项目的可见性。
\n\n适用于所有项目,但更适合公共项目:
\n\n\n
\n\n- \n
使用特殊
\n\nCI_REGISTRY_USER变量:为您创建此变量指定的用户,以便推送到连接到您的项目的注册表。它的密码是用CI_REGISTRY_PASSWORD变量自动设置的。这允许您自动构建和部署 Docker 映像,并具有对注册表的读/写访问权限。这是短暂的,因此它\xe2\x80\x99s 仅对一项作业有效。您可以按原样使用以下示例:Run Code Online (Sandbox Code Playgroud)docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY\n对于私人和内部项目:
\n\n\n
- \n
使用个人访问令牌:如果您的项目是私有的,您可以创建并使用个人访问令牌:
\n\n\n
\n\n- 对于读(拉)访问,范围应为
\nread_registry.- 对于读/写(拉/推)访问,请使用
\napi.替换以下示例中的
\n\n<username>和:<access_token>Run Code Online (Sandbox Code Playgroud)docker login -u <username> -p <access_token> $CI_REGISTRY\n使用 GitLab 部署令牌:您可以在您的私有项目中创建和使用特殊的部署令牌。它提供对注册表的只读(拉取)访问。创建后,您可以使用特殊的环境变量,GitLab …