我有web maven项目.Project的输出是一个war文件.我想将此war文件添加为project_b的依赖项.
project_b的pom.xml文件有一个插件如下:
...
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>geoserver</warName>
<webappDirectory>${project.build.directory}/geoserver</webappDirectory>
<packagingExcludes>WEB-INF/lib/servlet-api*.jar</packagingExcludes>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<GeoServerModule>core</GeoServerModule>
<Application-Name>${project.build.finalname}</Application-Name>
<Project-Version>${project.version}</Project-Version>
<Iteration-Name>${iteration}</Iteration-Name>
<Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
<Git-Revision>${build.commit.id}</Git-Revision>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
如何添加的warWeb应用程序与到project_b <groupId>org.itsme</groupId>,<artifactId>spring3-mvc-maven-xml-hello-world</artifactId>,<packaging>war</packaging>和<version>1.0-SNAPSHOT</version>?
我是一名java开发人员.我正在使用spring 4.0.1和hibernate 4.2.21.我有一个课程如下:
@Entity
@Inheritance(...)
public abstract class Feature{
@Id
@GeneratedValue
protected Long id;
...
}
Run Code Online (Sandbox Code Playgroud)
现在我有很多课程如下:
Label.java类:
@Entity
public class Label extends Feature{
protected String str;
...
}
Run Code Online (Sandbox Code Playgroud)
Point.java类:
@Entity
public class Point extends Feature{
protected Integer intg;
...
}
Run Code Online (Sandbox Code Playgroud)
我有超过20个从Feature类扩展的Entity 类.有没有办法在没有编写硬代码的情况下动态地将这些类(例如Label和Point)添加到项目中?
更新:
例如,Hibernate从数据库中获取数据,然后根据这些数据创建模型.
A.java
@Entity
@Getter
@Setter
@Inheritance
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, inclue=JsonTypeInfo.As.PROPERTY, property="type")
@JsonSubTypes({
@JsonSubTypes.Type(value=AA.class,name="aa"),
@JsonSubTypes.Type(value=AB.class,name="ab"),
})
public abstract class A {
@Id
@GeneratedValue
private Long id;
//json ignore for getter
@ManyToOne
private A parent;
@OneToMany(mappedBy="parent")
private List<A> children;
}
Run Code Online (Sandbox Code Playgroud)
AA.java
@Entity
@Getter
@Setter
@DiscriminatorValue("aa")
public class AA extends A{
private User user;
}
Run Code Online (Sandbox Code Playgroud)
AB.java
@Entity
@Getter
@Setter
@DiscriminatorValue("ab")
public class AB extends A {
private String name;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我将类的实例AB作为JSON 返回时,它看起来像这样:
{
"id": 1,
"type": "ab",
"children": [...],
"name": "ali"
}
Run Code Online (Sandbox Code Playgroud)
由于我想使用自定义User …
我是弹簧websocket的新手.我想将产品更改发送给客户.为此,我想按如下方式执行:客户端创建套接字连接并订阅目标:
var socket = new SockJS('/websocket');
var stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
stompClient.subscribe('/product/changes', function (scoredata) {
// We received product changes
});
});
//Send Ajax request and say server I want to know product with id=5 changes.
sendAjaxRequest(5);
Run Code Online (Sandbox Code Playgroud)
我已将弹簧应用程序配置如下:
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/websocket").withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/product/");
registry.setApplicationDestinationPrefixes("/app");
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要以下方法:
@RestController
public class ProductController {
@GetMapping("product-{id}")
public void startSubscribe(@PathVariable("id") Long …Run Code Online (Sandbox Code Playgroud) 我在 Java Web 应用程序中有一个可嵌入的实体,如下所示:
@Embeddable
@Getter
@Setter
public class Address {
private String street;
private String alley;
private int postCode;
}
Run Code Online (Sandbox Code Playgroud)
我在另一个实体中使用了一个嵌入字段,如下所示:
@Entity
@Getter
@Setter
public class User {
@Embedded
private Address home;
@Embedded
private Address work;
}
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,发生错误:
org.hibernate.MappingException:实体映射中的重复列:my.package.User 列:alley(应映射为 insert="false" update="false")。
我该如何解决?
笔记:
@AttributeOverrides。更新:
我使用的配置applicationContext.xml如下:
<bean id="mainSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>my.package</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
<prop key="hibernate.default_schema">public</prop> …Run Code Online (Sandbox Code Playgroud) 我是Spring Security oauth2的新手。我要运行此授权服务器示例代码。我成功运行了它,为了获得令牌,我将邮递员设置为如下,然后发送请求:
在这种情况下,我输入了带有其密码的客户端ID,但是我想在没有它们的情况下登录。例如,我的用户发送用户名,密码和客户端ID,然后获取令牌。但是我发送的每个请求,服务器都返回401响应。在Spring boot 2 oauth 2中,我该怎么做?
我正在将 spring JPA 与 PostgreSQL 数据库一起使用。我有一个实体如下:
@Entity
@TypeDef(name="json_binary", typeClass = com.vladmihalcea.hibernate.type.json.JsonBinaryType.class)
public class LiveTokens {
@Id
@GeneratedValue()
private Long id;
private String username;
@Type(type="json_binary")
@Column(columnDefinition = "jsonb")
private Token token
}
Run Code Online (Sandbox Code Playgroud)
和Token:
public class Token {
private Long expireTime;
private String accessToken;
}
Run Code Online (Sandbox Code Playgroud)
为了使用Hibernate将对象保存到列,我使用了Hibernate Types项目。现在我想获得LiveToken过期的All 。我不能用 Spring JPA 做到这一点。如何使用 Spring 数据 JPA 查询 posgresql jsonb 列?
我想web archive在我的tomcat网络服务器上运行geoserver .我正在使用tomcat 8.
我web archive从geoserver下载GeoServer 2.7.1.1 .当我想部署war文件时,出现错误如下:

但是当我部署另一个war应用程序时,它正确部署.
哪里有问题?
在 hibernate 中通过注释定义动态组件的等效方法是什么?
public abstract class CustomizableEntity {
private Map customProperties;
public Map getCustomProperties() {
if (customProperties == null)
customProperties = new HashMap();
return customProperties;
}
public void setCustomProperties(Map customProperties) {
this.customProperties = customProperties;
}
public Object getValueOfCustomField(String name) {
return getCustomProperties().get(name);
}
public void setValueOfCustomField(String name, Object value) {
getCustomProperties().put(name, value);
}
}
Run Code Online (Sandbox Code Playgroud)
我的实体:
public class Contact extends CustomizableEntity {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id …Run Code Online (Sandbox Code Playgroud) 为了在 postgresql 中保存 json 格式的列表,我com.vladmihalcea:hibernate-types-52在 Spring boot 2 中使用如下:
@Entity
@TypeDefs({
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class Profile {
...
@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private List<String> locations;
// getters & setters
}
Run Code Online (Sandbox Code Playgroud)
有了这个,一切都OK了,我可以将位置保存为postgresql中的json。但我想将位置保存为类继承结构。课程如下:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = SubClass1.class, name = "subClass1"),
@JsonSubTypes.Type(value = SubClass2.class, name = "subClass2")
})
public abstract class MyClass {
private String name;
// getters & setters
}
public class SubClass1 extends …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring 开发应用程序。在访问控制访问部分,我想使用 Spring Security Acl(我是 Acl 的新手)。我想基于 2 点在我的应用程序中实现 ACL:
read,create、modify、delete和Administrator。create权限,它应该能够read,或者当它有modify权限,它应该可以read,create和modify等。是否可以?如何?
更新:
我的应用程序基于 Spring MVC RESTFUL。当用户想要修改自己的信息时,他用ajax发送一些json数据。json数据示例如下:
{
"id": 1,//user Id
"name": "my name",
"password": "my password",
"email": "email@email.com",
...
}
Run Code Online (Sandbox Code Playgroud)
现在,恶意用户可以登录自己的帐户。该用户可以modify像所有其他用户一样拥有自己的数据。在他发送数据之前,更改他的id,以及modify另一个帐户的用户信息。我想用 ACL 来防止这种颠覆性的工作。并且用户可以访问其他人可以修改他的信息的其他人。
java ×10
hibernate ×4
spring ×3
spring-boot ×3
acl ×1
annotations ×1
dto ×1
dynamic ×1
geoserver ×1
jackson ×1
keycloak ×1
maven-plugin ×1
modelmapper ×1
postgresql ×1
sockjs ×1
spring-mvc ×1
tomcat8 ×1
webarchive ×1