跨境派

跨境派

跨境派,专注跨境行业新闻资讯、跨境电商知识分享!

当前位置:首页 > 跨境风云 > 史上最全springboot+vue3+element-plus代码实现web登录页面,包含maven配置

史上最全springboot+vue3+element-plus代码实现web登录页面,包含maven配置

时间:2024-04-24 16:40:34 来源:网络cs 作者:纳雷武 栏目:跨境风云 阅读:

标签: 配置  包含  实现 
阅读本书更多章节>>>>

前端代码

views目录下Login.vue,主要是登录页面的渲染及js信息,具体如下:

<template>  <div>    <div class="login-container">      <div style="width: 350px" class="login-box">        <div style="font-weight: bold;font-size:24px; text-align:center; margin-bottom: 30px ">登 录</div>        <el-form :model="data" ref="ruleFormRef" :rules="rules">          <el-form-item prop="userName">            <el-input  prefix-icon="User" v-model="data.userName" placeholder="请输入账号"/>          </el-form-item>          <el-form-item prop="password">            <el-input  prefix-icon="Lock" v-model="data.password" placeholder="请输入密码"/>          </el-form-item>          <el-form-item>            <el-button type="primary" style="width: 100%" @click="login"> 登 录 </el-button>          </el-form-item>        </el-form>        <div style="margin-top:30px; font-size: 12px ;text-align:right">          还没有账号?请<a href="/registor">注册</a>        </div>      </div>    </div>  </div></template><script setup >import {reactive,ref} from "vue"import loginApi from "@/api/login"const data = ref({})const rules = reactive({  userName: [    { required: true, message: '请输入账号', trigger: 'blur' }  ],  password: [    { required: true, message: '请输入密码', trigger: 'blur' }  ]})//http://localhost:9090/stu/loginconst ruleFormRef=ref({  userName:'',  password:'',})const login=()=>{   loginApi(data.value).then(res=>{     if(res.code===200){       console.log('result',"登录成功")     }else{       console.log('result',"登录失败")     }   }).catch(error=>{     console.log(error)     console.log('datassss',data)   })}</script><style scoped>.login-container{  min-height: 100vh;  overflow: hidden;  display: flex;  align-items: center;  justify-content: center;  background-image: url("@/assets/images/login.jpg");  background-size: cover;}.login-box{  background-color: rgba(200,200,200,.3);  box-shadow: 0 0 10px rgba(0,0,0,0.1);  padding:35px;}</style>

router目录下index.js:

路由处主要配置后端接口的路径:

import { createRouter, createWebHistory } from 'vue-router'import Home from '../views/Home.vue'import Login from '../views/Login.vue'import Registor from '../views/Registor.vue'const routes = [    {        path: '/',        name: 'Home',        component: Home    },    {        path: '/login',        name: 'Login',        component: Login    },    {        path: '/registor',        name: 'Registor',        component: Registor    }]const router = createRouter({    history: createWebHistory(),    routes})export default router

api目录下创建config.js、login.js、request.js
其中config.js主要配置请求的ip、端口以及拦截器和响应器,具体代码如下:

import axios from 'axios'import {ElMessage} from "element-plus";//创建axios实例const Service=axios.create({    baseURL:'http://localhost:9090',    headers:{        'Content-Type':'application/json;charset=UTF-8',        'Access-Control-Allow-Origin':'/*'    },    timeout:10000})//请求拦截器Service.interceptors.request.use((config)=>{    return config}, err => {    console.log(err);})//响应拦截器Service.interceptors.response.use((response)=>{    const res =response.data    if(res.code===200){        return res    }else{        ElMessage.error(res.message || '网络异常')        return res    }})export default Service

login.js主要配置登录的接口,相当于封装好,后面可以直接调用,代码如下:

import login from './request'const loginApi=data=>{    return login.post({        url:"/stu/login",        data    })}export default loginApi

request.js主要封装请求,类似于post、get、delete、put等,代码如下:

import Service from "./config"const get=(config)=>{    return Service({        ...config,        method:"get",        params:config.data    })}const post=(config)=>{    return Service({        ...config,        method:"post",        params:config.data    })}export default {    get,    post}

在vue中还有一些配置类的文件,其中,package.json主要是显示使用的组件信息,如element-plus等,包括版本及组件名称等,通过npm导入或者直接在里面添加都可以,具体代码如下:

{  "name": "vue_demo",  "version": "0.1.0",  "private": true,  "scripts": {    "serve": "vue-cli-service serve",    "build": "vue-cli-service build",    "lint": "vue-cli-service lint"  },  "dependencies": {    "@element-plus/icons-vue": "^2.3.1",    "axios": "^1.6.7",    "core-js": "^3.8.3",    "element-plus": "^2.5.6",    "vue": "^3.2.13",    "vue-router": "^4.3.0"  },  "devDependencies": {    "@babel/core": "^7.12.16",    "@babel/eslint-parser": "^7.12.16",    "@vue/cli-plugin-babel": "~5.0.0",    "@vue/cli-plugin-eslint": "~5.0.0",    "@vue/cli-service": "~5.0.0",    "eslint": "^7.32.0",    "eslint-plugin-vue": "^8.0.3"  },  "eslintConfig": {    "root": true,    "env": {      "node": true    },    "extends": [      "plugin:vue/vue3-essential",      "eslint:recommended"    ],    "parserOptions": {      "parser": "@babel/eslint-parser"    },    "rules": {}  },  "browserslist": [    "> 1%",    "last 2 versions",    "not dead",    "not ie 11"  ]}

vue.config.js配置一些全局的配置信息,具体代码如下:

const { defineConfig } = require('@vue/cli-service')module.exports = defineConfig({  transpileDependencies: true,  // 关闭eslint校验  lintOnSave: false})

后端代码:

controller层,主要写接口,具体代码如下:

package com.example.demo.controller;import com.alibaba.fastjson.JSON;import com.example.demo.entity.LoginInfo;import com.example.demo.entity.Result;import com.example.demo.entity.StuInfo;import com.example.demo.service.Login;import com.example.demo.service.StuManageService;import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.*;import java.util.List;@RestController@Slf4jpublic class WebController {    @Autowired    private StuManageService stuManageService;    @Autowired    private Login login;    @GetMapping("/first")    public String firstRequest(){        return "这是一个测试接口";    }    @PostMapping (value="/stu/login")    public Result login(@RequestBody LoginInfo loginInfo){        log.info("LoginInfo"+JSON.toJSONString(loginInfo));        LoginInfo loginInfo1 = login.getLoginInfo(loginInfo);        Result result=new Result();        result.setCode(200);        result.setMsg("成功");        result.setData(JSON.toJSONString(loginInfo1));        return result;    }    @GetMapping("/getInfo")    public List<StuInfo> getStuInfoList(){        return stuManageService.getStuList();    }}

service层,主要写业务逻辑,具体代码如下:

package com.example.demo.service;import com.alibaba.fastjson.JSON;import com.example.demo.dao.LoginInfoMapper;import com.example.demo.entity.LoginInfo;import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Slf4j@Servicepublic class Login {    @Autowired    private LoginInfoMapper loginInfoMapper;        public LoginInfo getLoginInfo(LoginInfo loginInfo){        log.info("请求参数####"+ JSON.toJSONString(loginInfo));        LoginInfo loginInfo1 = loginInfoMapper.selectLoginInfo(loginInfo);        //没有用户        if(loginInfo1==null){            throw new RuntimeException("账号或用户名密码错误");        }        if(!loginInfo1.getPassword().equals(loginInfo.getPassword())){            throw new RuntimeException("账号或用户名密码错误");        }        return loginInfo1;    }}
package com.example.demo.service;import com.example.demo.dao.StuInfoMapper;import com.example.demo.entity.StuInfo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import javax.annotation.Resource;import java.util.List;@Servicepublic class StuManageService {    @Autowired    private StuInfoMapper stuInfoMapper;    public List<StuInfo> getStuList(){        return stuInfoMapper.selectStu();    }}

dao层,主要是与数据库交互,具体代码和xml如下:

package com.example.demo.dao;import com.example.demo.entity.LoginInfo;import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import org.springframework.stereotype.Repository;@Mapperpublic interface LoginInfoMapper {    LoginInfo selectLoginInfo(@Param("loginInfo")LoginInfo loginInfo );}
package com.example.demo.dao;import com.example.demo.entity.StuInfo;import org.apache.ibatis.annotations.Mapper;import org.springframework.stereotype.Component;import org.springframework.stereotype.Repository;import java.util.List;@Mapper@Repositorypublic interface StuInfoMapper{    List<StuInfo> selectStu();}
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.example.demo.dao.LoginInfoMapper">    <select id="selectLoginInfo" resultType="com.example.demo.entity.LoginInfo">        select * from login where user_name=#{loginInfo.userName}    </select></mapper>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.example.demo.dao.StuInfoMapper">    <select id="selectStu" resultType="com.example.demo.entity.StuInfo">        select * from stu_info    </select>    <insert id="insertStu" parameterType="com.example.demo.entity.LoginInfo">        insert into stu_info(user_name,password) values(#{userName},#{password})    </insert></mapper>

entity层,主要是封装的属性,具体代码如下:

package com.example.demo.entity;import lombok.Data;@Datapublic class LoginInfo {    private String userName;    private String password;}
package com.example.demo.entity;import lombok.Data;@Datapublic class Result {    private Integer code;    private String msg;    private String data;}
package com.example.demo.entity;import lombok.Data;@Datapublic class StuInfo {    private Integer id;    private String name;    private String sex;    private Integer age;}

conf目录主要配置一些全局信息的配置,其中,CorsConfig主要添加一些跨域配置,具体代码如下:

package com.example.demo.conf;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.cors.CorsConfiguration;import org.springframework.web.cors.UrlBasedCorsConfigurationSource;import org.springframework.web.filter.CorsFilter;@Configurationpublic class CorsConfig {    @Bean    public CorsFilter corsFilter(){        //创建CORS过滤器对象        CorsConfiguration corsConfiguration = new CorsConfiguration();        //接下去就是设置http头信息        corsConfiguration.addAllowedOrigin("*"); //设置允许跨域请求的域名        corsConfiguration.addAllowedHeader("*"); //设置请求头字段        corsConfiguration.addAllowedMethod("*"); //设置允许的请求方式        // 设置允许跨域的路径        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();        source.registerCorsConfiguration("/**",corsConfiguration);        return new CorsFilter(source);    }}

tomcat的一些配置,具体代码如下:

package com.example.demo.conf;import org.apache.catalina.connector.Connector;import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class TomcatConfig {    @Bean    public TomcatServletWebServerFactory webServerFactory() {        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();        factory.addConnectorCustomizers((Connector connector) -> {            connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");            connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");        });        return factory;    }}

后端数据库连接的一些配置,以及mapper读取的一些配置,首先是application.properties,具体如下:

server.port=9090spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.url=jdbc:mysql://127.0.0.1:3306/student_manage?useUnicode=true&characterEncoding=utf8spring.datasource.username=rootspring.datasource.password=yuluo15200342100#配置mapper xml文件的路径mybatis.type-aliases-package=com.example.demo.entitymybatis.mapper-locations=classpath:com/example/demo/dao/mapper/*.xmllogging.config: classpath:logback-spring.xml

日志打印设置信息,配置在logback-spring.xml,具体如下:

<?xml version="1.0" encoding="UTF-8"?><configuration>    <!-- 此xml在spring-boot-1.5.3.RELEASE.jar里 -->    <include resource="org/springframework/boot/logging/logback/defaults.xml" />    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />    <!-- 开启后可以通过jmx动态控制日志级别(springboot Admin的功能) -->    <!--<jmxConfigurator/>-->    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">        <!--<File>/home/hfw-client/hfw_log/stdout.log</File>-->        <File>D:/log/hfw-client/hfw_log/stdout.log</File>        <encoder>            <pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern>        </encoder>        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">            <!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->            <!--<fileNamePattern>/home/hfw-client/hfw_log/stdout.log.%d{yyyy-MM-dd}.log</fileNamePattern>-->            <fileNamePattern>D:/log/hfw-client/hfw_log/stdout.log.%d{yyyy-MM-dd}.log</fileNamePattern>            <maxHistory>30</maxHistory><!--  保留30天日志 -->        </rollingPolicy>    </appender>    <logger name="com.example.demo.dao" level="INFO" />    <root level="INFO">        <appender-ref ref="CONSOLE"/>        <appender-ref ref="FILE"/>    </root></configuration>

pom.xml的具体信息如下:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <parent>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-parent</artifactId>        <version>2.5.14</version>        <relativePath/> <!-- lookup parent from repository -->    </parent>    <groupId>com.example</groupId>    <artifactId>demo</artifactId>    <version>0.0.1-SNAPSHOT</version>    <name>demo</name>    <description>Demo project for Spring Boot</description>    <properties>        <java.version>1.8</java.version>    </properties>    <dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-test</artifactId>            <scope>test</scope>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-jdbc</artifactId>        </dependency>        <!--Spring boot 核心-->        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-data-jpa</artifactId>        </dependency>        <!--Mysql依赖包-->        <dependency>            <groupId>mysql</groupId>            <artifactId>mysql-connector-java</artifactId>        </dependency>        <!-- druid数据源驱动 -->        <dependency>            <groupId>com.alibaba</groupId>            <artifactId>druid</artifactId>            <version>1.1.6</version>        </dependency>        <dependency>            <groupId>org.lionsoul</groupId>            <artifactId>ip2region</artifactId>            <version>1.7.2</version>        </dependency>        <!--myabtis-->        <dependency>            <groupId>org.mybatis.spring.boot</groupId>            <artifactId>mybatis-spring-boot-starter</artifactId>            <version>2.1.2</version>        </dependency>        <!--lombok-->        <dependency>            <groupId>org.projectlombok</groupId>            <artifactId>lombok</artifactId>            <optional>true</optional>        </dependency>        <dependency>            <groupId>com.alibaba</groupId>            <artifactId>fastjson</artifactId>            <version>1.2.47</version>        </dependency>        <dependency>            <groupId>org.projectlombok</groupId>            <artifactId>lombok</artifactId>            <version>1.16.20</version>            <scope>provided</scope>        </dependency>        <dependency>            <groupId>org.openjdk.jol</groupId>            <artifactId>jol-core</artifactId>            <version>0.9</version>        </dependency>    </dependencies>    <build>        <resources>            <resource>                <directory>src/main/java</directory>                <includes>                    <include>**/*.xml</include>                </includes>                <filtering>false</filtering>            </resource>            <!-- 扫描resources下所有资源 -->            <resource>                <directory>src/main/resources</directory>                <includes>                    <include>**/*.*</include>                </includes>            </resource>        </resources>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>            </plugin>        </plugins>    </build></project>

Maven的setting.xml信息。具体如下:

<?xml version="1.0" encoding="UTF-8"?><!--Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements.  See the NOTICE filedistributed with this work for additional informationregarding copyright ownership.  The ASF licenses this fileto you under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliancewith the License.  You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied.  See the License for thespecific language governing permissions and limitationsunder the License.--><!-- | This is the configuration file for Maven. It can be specified at two levels: | |  1. User Level. This settings.xml file provides configuration for a single user, |                 and is normally provided in ${user.home}/.m2/settings.xml. | |                 NOTE: This location can be overridden with the CLI option: | |                 -s /path/to/user/settings.xml | |  2. Global Level. This settings.xml file provides configuration for all Maven |                 users on a machine (assuming they're all using the same Maven |                 installation). It's normally provided in |                 ${maven.conf}/settings.xml. | |                 NOTE: This location can be overridden with the CLI option: | |                 -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  <!-- localRepository   | The path to the local repository maven will use to store artifacts.   |   | Default: ${user.home}/.m2/repository  <localRepository>/path/to/local/repo</localRepository>  --> <localRepository>D:\Maven\apache-maven-3.6.3\maven-repository</localRepository>  <!-- interactiveMode   | This will determine whether maven prompts you when it needs input. If set to false,   | maven will use a sensible default value, perhaps based on some other setting, for   | the parameter in question.   |   | Default: true  <interactiveMode>true</interactiveMode>  -->  <!-- offline   | Determines whether maven should attempt to connect to the network when executing a build.   | This will have an effect on artifact downloads, artifact deployment, and others.   |   | Default: false  <offline>false</offline>  -->  <!-- pluginGroups   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.   |-->  <pluginGroups>    <!-- pluginGroup     | Specifies a further group identifier to use for plugin lookup.    <pluginGroup>com.your.plugins</pluginGroup>    -->  </pluginGroups>  <!-- proxies   | This is a list of proxies which can be used on this machine to connect to the network.   | Unless otherwise specified (by system property or command-line switch), the first proxy   | specification in this list marked as active will be used.   |-->  <proxies>    <!-- proxy     | Specification for one proxy, to be used in connecting to the network.     |    <proxy>      <id>optional</id>      <active>true</active>      <protocol>http</protocol>      <username>proxyuser</username>      <password>proxypass</password>      <host>proxy.host.net</host>      <port>80</port>      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>    </proxy>    -->  </proxies>  <!-- servers   | This is a list of authentication profiles, keyed by the server-id used within the system.   | Authentication profiles can be used whenever maven must make a connection to a remote server.   |-->  <servers>    <!-- server     | Specifies the authentication information to use when connecting to a particular server, identified by     | a unique name within the system (referred to by the 'id' attribute below).     |     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are     |       used together.     |    <server>      <id>deploymentRepo</id>      <username>repouser</username>      <password>repopwd</password>    </server>    -->    <!-- Another sample, using keys to authenticate.    <server>      <id>siteServer</id>      <privateKey>/path/to/private/key</privateKey>      <passphrase>optional; leave empty if not used.</passphrase>    </server>    -->  </servers>  <!-- mirrors   | This is a list of mirrors to be used in downloading artifacts from remote repositories.   |   | It works like this: a POM may declare a repository to use in resolving certain artifacts.   | However, this repository may have problems with heavy traffic at times, so people have mirrored   | it to several places.   |   | That repository definition will have a unique id, so we can create a mirror reference for that   | repository, to be used as an alternate download site. The mirror site will be the preferred   | server for that repository.   |-->  <mirrors>    <!-- mirror     | Specifies a repository mirror site to use instead of a given repository. The repository that     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.     |    <mirror>      <id>mirrorId</id>      <mirrorOf>repositoryId</mirrorOf>      <name>Human Readable Name for this Mirror.</name>      <url>http://my.repository.com/repo/path</url>    </mirror>     -->     <!-- 闃块噷浜戞湇鍔″櫒閰嶇疆 --> <mirror><id>nexus-aliyun</id><mirrorOf>*</mirrorOf><name>Nexus aliyun</name><url>http://maven.aliyun.com/nexus/content/groups/public</url></mirror>  </mirrors>  <!-- profiles   | This is a list of profiles which can be activated in a variety of ways, and which can modify   | the build process. Profiles provided in the settings.xml are intended to provide local machine-   | specific paths and repository locations which allow the build to work in the local environment.   |   | For example, if you have an integration testing plugin - like cactus - that needs to know where   | your Tomcat instance is installed, you can provide a variable here such that the variable is   | dereferenced during the build process to configure the cactus plugin.   |   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles   | section of this document (settings.xml) - will be discussed later. Another way essentially   | relies on the detection of a system property, either matching a particular value for the property,   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.   | Finally, the list of active profiles can be specified directly from the command line.   |   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact   |       repositories, plugin repositories, and free-form properties to be used as configuration   |       variables for plugins in the POM.   |   |-->  <profiles>    <!-- profile     | Specifies a set of introductions to the build process, to be activated using one or more of the     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>     | or the command line, profiles have to have an ID that is unique.     |     | An encouraged best practice for profile identification is to use a consistent naming convention     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.     | This will make it more intuitive to understand what the set of introduced profiles is attempting     | to accomplish, particularly when you only have a list of profile id's for debug.     |     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.    <profile>      <id>jdk-1.4</id>      <activation>        <jdk>1.4</jdk>      </activation>      <repositories>        <repository>          <id>jdk14</id>          <name>Repository for JDK 1.4 builds</name>          <url>http://www.myhost.com/maven/jdk14</url>          <layout>default</layout>          <snapshotPolicy>always</snapshotPolicy>        </repository>      </repositories>    </profile>    -->    <!--     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration     | might hypothetically look like:     |     | ...     | <plugin>     |   <groupId>org.myco.myplugins</groupId>     |   <artifactId>myplugin</artifactId>     |     |   <configuration>     |     <tomcatLocation>${tomcatPath}</tomcatLocation>     |   </configuration>     | </plugin>     | ...     |     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to     |       anything, you could just leave off the <value/> inside the activation-property.     |    <profile>      <id>env-dev</id>      <activation>        <property>          <name>target-env</name>          <value>dev</value>        </property>      </activation>      <properties>        <tomcatPath>/path/to/tomcat/instance</tomcatPath>      </properties>    </profile>    -->    <!-- jdk閰嶇疆 --> <profile>      <id>jdk-1.8</id>      <activation>    <activeByDefault>true</activeByDefault>        <jdk>1.8</jdk>      </activation>      <properties>        <maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>      </properties></profile>  </profiles>  <!-- activeProfiles   | List of profiles that are active for all builds.   |  <activeProfiles>    <activeProfile>alwaysActiveProfile</activeProfile>    <activeProfile>anotherAlwaysActiveProfile</activeProfile>  </activeProfiles>  --></settings>
阅读本书更多章节>>>>

本文链接:https://www.kjpai.cn/fengyun/2024-04-24/161899.html,文章来源:网络cs,作者:纳雷武,版权归作者所有,如需转载请注明来源和作者,否则将追究法律责任!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。

文章评论