我们需要使用Maven构建一个jar,它包含所有依赖项,但是所有这些依赖项都被重命名(重定位).
假设我们自己的包都以com.mycompagny.projectx.*".我们希望项目依赖项将其包重命名为以" embedded" 开头,而不是我们自己的类.
以maven-shade-plugin为例,我无法做到这一点:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<createDependencyReducedPom>true</createDependencyReducedPom>
<artifactSet>
<includes>
<include>*.*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>*</pattern>
<shadedPattern>embedded.</shadedPattern>
<excludes>
<exclude>com.mycompagny.projectx.*</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这<pattern>*</pattern>是无效的.另外,如果我使用<pattern></pattern>(空字符串),那么所有内容都会重新定位到"嵌入式"包,甚至是资源("META-INF"目录)!当然,我们希望资源保留在jar的根部.
我想我们可以创建多个<relocation>要素,一个是依赖的每个包,但是这将是大量的工作:<relocation>com</relocation>,<relocation>net</relocation>,<relocation>javax</relocation>等.
如何轻松地重新定位超级jar中的所有依赖项,而不涉及我们自己的类,资源和"META-INF"目录?
我试图了解如何使用Json Web Tokens在单点登录架构中实现注销功能.
假设我们有:
example1.comexample2.comauthserver.com当用户必须进行身份验证时example1.com,会将authserver.com其重定向到验证用户凭据,创建已签名的JWT令牌并example1.com使用此令牌将用户重定向回.example1.com然后将设置一个cookie(或LocalStorage密钥),并且example1.com只要该令牌未过期,就会对用户进行身份验证.无需更多呼叫即可authserver.com识别用户.
然后用户前往example2.com参与SSO体系结构.用户也需要在那里进行身份验证,因此example2.com还要将用户重定向到authserver.com识别用户的用户(使用第一次设置的cookie),创建新的JWT令牌并自动将用户重定向回example2.com.example2.com然后将设置一个cookie(或LocalStorage密钥),并且example2.com只要该令牌未过期,就会对用户进行身份验证.无需更多呼叫即可authserver.com识别用户.
现在,如何实施"注销"功能?
如果用户注销example1.com,example1.com则会删除JWT令牌,并且不再对用户进行身份验证.但是当他试图到达受保护区域时,example1.com会将其重定向到authserver.com,用户将被识别并再次自动登录...即使他刚刚退出!
Quetion 1)所以我想当用户注销时example1.com,authserver.com必须进行调用才能删除设置的cookie,authserver.com这样用户就不会再自动登录了?
排队2)如果是这样,那该怎么example2.com办?用户是否还应该在那里进行身份验证?如果没有,建议的流程是example2.com什么,因此知道它对用户的JWT令牌不再有效?
使用Visual Studio代码,是否可以禁用特定文件(或扩展名)的格式?
我尝试使用一些Handlebars模板,我根本不希望VSCode格式化它们.一个简单的例子是:
{{test1}}
{{test2}}
Run Code Online (Sandbox Code Playgroud)
当我保存这个文件(我确实有 - 并希望 - "editor.formatOnSave"设置为true)时,VsCode将内容转换为
{{test1}} {{test2}}
Run Code Online (Sandbox Code Playgroud)
我发现文件保持不变的唯一方法是将其命名为" template.txt"而不是" template.hbs".
任何的想法?
我知道这可能是一个经典的javascript问题,但我经常发现自己使用:
if (!something) {
//...
}
Run Code Online (Sandbox Code Playgroud)
在TypeScript中验证这something不是undefined或null.
这非常容易出错!当用在number"0"上时会匹配,当在enum第一个项目上使用时也会匹配(默认情况下,第一个项目的值为"0")!
有没有办法在TypeScript中处理这个问题?有没有办法配置TypeScript以禁止除boolean(和any)之外的任何内容的感叹号?这种配置是否有意义,或者我错过了一些微不足道的东西?
应该 :
if (something === null || something === undefined) {
//...
}
Run Code Online (Sandbox Code Playgroud)
相反,用来验证是否定义了某些东西?有没有办法在团队中强制执行此操作?
我们使用Resteasy并且在如何调用某些@GET方法时遇到问题.
如果方法的接口只有简单的参数,则没有问题.例如:
@GET
@Path("/test/{myparam}")
public FacetQueryResultImpl testMethod(@PathParam("myparam")String myparam);
Run Code Online (Sandbox Code Playgroud)
但是如果我们尝试使用POJO作为参数,似乎RestEasy无法将其序列化为查询字符串参数.例如:
@GET
@Path("/testGet")
public FacetQueryResultImpl testMethod(ParamPojo myparam);
Run Code Online (Sandbox Code Playgroud)
要么
@GET
@Path("/testGet")
public FacetQueryResultImpl testMethod(@QueryParam("myparam")ParamPojo myparam);
Run Code Online (Sandbox Code Playgroud)
(用,ParamPojo.java :)
public class ParamPojo
{
private String name;
private String description;
(...)
}
Run Code Online (Sandbox Code Playgroud)
当我们尝试这个时,有时候找不到服务,有时候我们会得到"A GET请求不能有一个身体".例外.
使用@POST我们可以使用POJO具有参数,但是我们的一些方法不会修改服务器上的任何内容,因此应该使用@GET.
解决方法是"爆炸"ParamPojo,并将其所有属性用作方法的分离参数.但这消除了"RestEasy"中的"Easy"部分,不是吗?
我尝试在Spring MVC 3.1应用程序中使用Hibernate 4.1.5.Final.
(更新:现在Hibernate 4.1.6.Final和Spring 3.1.2.RELEASE,但仍然没有运气!)
当我尝试删除一个实体时,我得到一个例外,我不明白.
以下是涉及的两个主要类别:
用户:
@Entity
@Table(name="usertable")
public class User extends BaseModel
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@OneToOne(optional=true, cascade=CascadeType.ALL, mappedBy="user", orphanRemoval=true, fetch=FetchType.LAZY)
private FacebookAccount facebookAccount;
// ...
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public FacebookAccount getFacebookAccount()
{
return facebookAccount;
}
public void setFacebookAccount(FacebookAccount facebookAccount)
{
this.facebookAccount = facebookAccount;
}
}
Run Code Online (Sandbox Code Playgroud)
脸书账号 :
@Entity
@Table(name="facebookAccount")
public class FacebookAccount extends BaseModel
{
@Id
@GeneratedValue(strategy …Run Code Online (Sandbox Code Playgroud) 使用maven-shade-plugin,有没有办法排除依赖(不是"提供")及其所有传递依赖?
例如 :
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>some-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
... other dependencies
</dependencies>
Run Code Online (Sandbox Code Playgroud)
和1)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
<excludes>
<exclude>com.example:some-artifact</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
或2)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>com.example:some-artifact</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
那些不起作用.所有传递依赖com.example:some-artifact …
我有一个版本0.1.0的任务,我尝试迁移到2.0.0.
此任务只是使用Gulp脚本将Typescript转换为Javascript.输出显示在"输出"控制台中,没有涉及终端,我希望它保持这种方式(主要是因为Terminal will be reused by tasks, press any key to close it.在终端的任何命令结束时臭名昭着的消息" ").
我无法看到如何将此任务迁移到2.0.0版本,因此不涉及终端!
这是版本0.1.0:
{
"version": "0.1.0",
"command": "${workspaceRoot}/node_modules/.bin/gulp",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"taskName": "compile",
"args": [
"compile",
"exit"
],
"isBuildCommand": true,
"problemMatcher": "$tsc"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我目前对2.0.0版的尝试:
{
"version": "2.0.0",
"tasks": [
{
"identifier": "compile",
"type": "shell",
"taskName": "compile",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "new"
},
"command": "${workspaceRoot}/node_modules/.bin/gulp compile exit",
"problemMatcher": [ …Run Code Online (Sandbox Code Playgroud) 我正在使用INSERT ... ON CONFLICT ...能够在 PostgreSQL 表中插入一些数据。
但是现在我还希望能够删除一些现有的行,如果它们不是由当前INSERT查询提供的。所以,除了INSERTand 之外UPDATE,我希望能够做一个DELETE.
使用SQL Server,我会使用MERGE查询和:
WHEN NOT MATCHED BY SOURCE THEN DELETE
Run Code Online (Sandbox Code Playgroud)
使用 实现类似功能的推荐方法是什么PostgreSQL?
我宁愿不要运行两个单独的查询。
我正在框架中实现CORS(跨域资源共享)。
我知道,当使用Jquery发出XMLHttpRequest请求ajax(...)且withCredentials属性为时true,服务器必须响应这两件事:
Access-Control-Allow-Credentials: trueAccess-Control-Allow-Origin:[THE_DOMAIN]服务器无法使用通配符响应Access-Control-Allow-Origin:*:无效!
我的问题:我怎么知道服务器withCredentials: true上已经使用过,所以我不使用通配符?
我比较了使用withCredentials: false时withCredentials: true和使用时发送的标头,它们是相同的!
因此,如果我确实想在客户端请求时允许凭据,这是否意味着我永远无法使用Access-Control-Allow-Origin:*?
java ×3
javascript ×2
maven ×2
ajax ×1
cors ×1
hibernate ×1
jar ×1
jax-rs ×1
jpa ×1
jquery ×1
jwt ×1
postgresql ×1
resteasy ×1
spring-mvc ×1
sql ×1
tslint ×1
typescript ×1