分类 Code 下的文章

局部 {M2_HOME}/conf/settings.xml
全局 ~/.m2/settings.xml

<settings>
    <proxies>
        <proxy>
            <id>httpproxy</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>your-proxy-host</host>
            <port>your-proxy-port</port>
            <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        <proxy>
            <id>httpsproxy</id>
            <active>true</active>
            <protocol>https</protocol>
            <host>your-proxy-host</host>
            <port>your-proxy-port</port>
            <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
    </proxies>
</settings>

@Entity
public class Shirt implements Serializable {

    @Id
    @Size(max=9)
    private String id;

    @ElementCollection
    @CollectionTable(
        name = "SHIRT_COLORS",
        joinColumns=@JoinColumn(name = "id", referencedColumnName = "id")
    )
    @Column(name="color")
    private List<String> colors = new ArrayList<String>();
    ...
https://stackoverflow.com/questions/22075199/jpa-elementcollection-list-specify-join-column-name

@Column(nullable=false) 是生成模式的指令。从该类生成的数据库列将在实际数据库中标记为不可空。

optional=false 是一条运行时指令。它的主要功能与懒加载有关。除非你记得设置 optional=false,否则你就无法懒加载一个非集合映射实体(因为 Hibernate 不知道那里应该有一个代理还是一个空值,除非你告诉它空值是不可能的,所以它可以生成一个代理)。

https://stackoverflow.com/questions/3331907/what-is-the-difference-between-manytooneoptional-false-vs-columnnullable-f

1.Get the User in a Bean

The simplest way to retrieve the currently authenticated principal is via a static call to the SecurityContextHolder:

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName();

An improvement to this snippet is first checking if there is an authenticated user before trying to access it:

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof AnonymousAuthenticationToken)) {
    String currentUserName = authentication.getName();
    return currentUserName;
}

- 阅读剩余部分 -