Spring Security项目构建(一)

源码地址

Github

项目构建

image.png

依赖关系

image.png

代码结构

security:主模块 security-core:核心业务逻辑 security-browser:浏览器安全特定代码 security-app:app相关特定代码 security-demo:样例程序

包引入

主模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>guosh.security.com</groupId>
    <artifactId>guosh-security</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <guosh.security.version>1.0-SNAPSHOT</guosh.security.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Brussels-SR11</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source> <!-- 源代码使用的开发版本 -->
                    <target>1.8</target> <!-- 需要生成的目标class文件的编译版本 -->
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>guoshsecuritycore</module>
        <module>guoshsecuritybrowser</module>
        <module>guoshsecurityapp</module>
        <module>guoshsecuritydemo</module>
    </modules>


</project>

core模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>guosh-security</artifactId>
        <groupId>guosh.security.com</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>guosh-security-core</artifactId>

    <dependencies>
        <!--oauth2认证-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!--第三方登陆-->
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-web</artifactId>
        </dependency>
        <!--工具类-->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
        </dependency>
    </dependencies>

</project>

browser模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>guosh-security</artifactId>
        <groupId>guosh.security.com</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>guosh-security-browser</artifactId>

    <dependencies>
        <dependency>
            <groupId>guosh.security.com</groupId>
            <artifactId>guosh-security-core</artifactId>
            <version>${guosh.security.version}</version>
        </dependency>
        <!--session集群-->
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session</artifactId>
        </dependency>
    </dependencies>

</project>

app 模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>guosh-security</artifactId>
        <groupId>guosh.security.com</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>guosh-security-app</artifactId>

    <dependencies>
        <dependency>
            <groupId>guosh.security.com</groupId>
            <artifactId>guosh-security-core</artifactId>
            <version>${guosh.security.version}</version>
        </dependency>
    </dependencies>
</project>

demo 模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>guosh-security</artifactId>
        <groupId>guosh.security.com</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>guosh-security-demo</artifactId>

    <dependencies>
        <dependency>
            <groupId>guosh.security.com</groupId>
            <artifactId>guosh-security-browser</artifactId>
            <version>${guosh.security.version}</version>
        </dependency>
    </dependencies>

    <build>
        <!--打完包的名字-->
        <finalName>guoshsecurity</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Hello程序

现在需要把项目启动起来所以做了一个Demo

1.在Demo下面新建yml文件并连接数据库

image.png

2.新建Spring boot的启动文件,添加一个/hello测试

image.png

3.执行main函数查看

image.png

4.打包测试

使用maven打包命令生成jar包之后可以使用

java  -jar  ./guoshsecurity.jar 启动

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

编辑于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏用户2442861的专栏

CentOS安装配置cmake

安装环境:CentOS-6.3 安装方式:源码编译安装  软件:cmake-2.8.10.2.tar.gz 下载地址:http://www.cmake....

1403
来自专栏康怀帅的专栏

Linux systemd 定时器 timer

用来取代 crontab systemd 系列文章请查看:https://www.khs1994.com/tags/systemd/ 要使用定时器必须编写两个...

3804
来自专栏FreeBuf

Galileo:一款开源Web应用审计框架

Galileo是一款针对Web应用程序的开源渗透测试工具,可帮助开发和渗透测试人员识别并利用其Web应用程序中的漏洞。

1083
来自专栏Pythonista

Mac下Python和Pycharm之virtualenv

1013
来自专栏拂晓风起

Django学习入门步骤 教程步骤 python

1444
来自专栏郭少华

Spring Security项目构建(一)

1362
来自专栏禁心尽力

下载安装ActiveMQ(消息队列)

安装步骤: 第一步、安装jdk环境,因为ActiveMQ是使用java语言编写。 第二步、将下载好的activemq压缩包上传至Linux系统,进行解压。 第三...

2265
来自专栏magicsoar

mac下使用marsedit写博客

在Windows习惯了使用Windows live write写好博客,然后发布上去,到了mac下,发现了一个很好的替代品  MarseEdit 下载安装后,打...

3049
来自专栏Android相关

Ijkplayer编译

ijkplayer最好用ndk-r10e来进行编译,否则会出现很多Cmake等等问题

2253
来自专栏IT笔记

SpringBoot开发案例之Actuator健康监控

在秒杀案例进入实际生产环境中,需要实时或定期监控服务的可用性。Spring Boot 的 actuator(健康监控)功能提供了很多监控所需的接口,可以对应用系...

1022

扫码关注云+社区

领取腾讯云代金券