升级了!2003->2005

唉,裸奔终于遭报应了。 我连续2次中了一个蠕虫病毒。重新装了又中。。。。。

第一次我使用卡巴斯基杀毒,用了9个小时。而且,那是实施保护太费资源了。。。所以,我把它关上之后,又中病毒了。

后来,我转而用瑞星了,用了2天,似乎没有什么问题了。

既然重新安装了操作系统,VC++就要重装了。既然是重装,就不用拘泥于2003了,终于可以赶上潮流用2005了。

不过听说2008也快出了,唉,我的垃圾电脑,要带的东西又多了。。。

 

看看2005和2003有什么不同吧!

小人不才,最大的不同应该就是资源列表从右边变到左边来了。。。

然后下面多了个定义查询,这个可以方便看打错了没有。。。。

其他方面和2003用法是一样的,至少我用到的部分就是这些不同了。。。不要笑我,我就会那么一点。

<!-- 开发 --&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <!--默认激活配置--&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; <!--当前环境--&gt; <profile.name&gt;dev</profile.name&gt; <!--配置文件前缀--&gt; <prefix.name&gt;jeecg</prefix.name&gt; <!--Nacos配置中心地址192.168.2.236:8848,--&gt; <config.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</config.server-addr&gt; <!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空--&gt; <config.namespace/&gt; <!--Nacos配置分组名称--&gt; <config.group&gt;DEFAULT_GROUP</config.group&gt; <!--Nacos服务发现地址--&gt; <discovery.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</discovery.server-addr&gt; </properties&gt; </profile&gt; <!-- 达梦开发环境 --&gt; <!-- <profile&gt;--&gt; <!-- <id&gt;dm-dev</id&gt;--&gt; <!-- <activation&gt;--&gt; <!-- <!–默认激活配置–&gt;--&gt; <!-- <activeByDefault&gt;true</activeByDefault&gt;--&gt; <!-- </activation&gt;--&gt; <!-- <properties&gt;--&gt; <!-- <!–当前环境–&gt;--&gt; <!-- <profile.name&gt;dm-dev</profile.name&gt;--&gt; <!-- <!–配置文件前缀–&gt;--&gt; <!-- <prefix.name&gt;jeecg</prefix.name&gt;--&gt; <!-- <!–Nacos配置中心地址192.168.2.236:8848,–&gt;--&gt; <!-- <config.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</config.server-addr&gt;--&gt; <!-- <!–Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空–&gt;--&gt; <!-- <config.namespace/&gt;--&gt; <!-- <!–Nacos配置分组名称–&gt;--&gt; <!-- <config.group&gt;DEFAULT_GROUP</config.group&gt;--&gt; <!-- <!–Nacos服务发现地址–&gt;--&gt; <!-- <discovery.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</discovery.server-addr&gt;--&gt; <!-- </properties&gt;--&gt; <!-- </profile&gt;--&gt;为什么我加了一个就不识别了
08-14
<think&gt;问题描述:在Maven的pom.xml中配置了多个profile,但是当添加一个新的profile(例如达梦开发环境)后,发现不识别了。 分析:从提供的pom.xml片段来看,原来有一个id为`dev`的profile,然后尝试添加一个id为`dm-dev`的profile,但是被注释掉了。用户说“加了一个就不识别了”,可能是指取消注释后,新的profile没有被正确识别。 可能的原因: 1. **语法错误**:取消注释后,可能由于XML结构问题(比如标签未正确闭合、注释符号残留等)导致整个配置文件出错。 2. **激活问题**:新添加的profile没有正确激活,或者多个profile同时激活导致冲突。 3. **Maven命令问题**:运行Maven时没有指定使用哪个profile。 解决方案: ### 1. 检查XML语法 确保新添加的profile部分没有语法错误。特别注意: - 每个profile必须有一个唯一的id。 - 整个profile块必须被正确包裹在`<profiles&gt;`标签内。 - 注释符号(`<!--` 和 `--&gt;`)必须成对出现,且不能嵌套。 示例:取消注释后,两个profile的配置应该是这样的: ```xml <profiles&gt; <!-- 开发 --&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <!--默认激活配置--&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; ... </properties&gt; </profile&gt; <!-- 达梦开发环境 --&gt; <profile&gt; <id&gt;dm-dev</id&gt; <activation&gt; <!--默认激活配置--&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; ... </properties&gt; </profile&gt; </profiles&gt; ``` 注意:两个profile都设置了`<activeByDefault&gt;true</activeByDefault&gt;`,这意味着它们都会默认激活。但是,Maven不允许同时激活两个默认的profile,这可能导致问题。 ### 2. 解决默认激活冲突 如果两个profile都设置了`<activeByDefault&gt;true</activeByDefault&gt;`,则Maven只会激活第一个(按定义顺序)默认激活的profile。第二个profile不会被激活。 解决方案: - 如果希望两个profile同时激活,则不应该使用`activeByDefault`,而是通过其他方式激活(如使用`-P`参数显式指定)。 - 或者,只保留一个默认激活的profile。 例如,修改达梦开发环境的profile,移除默认激活: ```xml <profile&gt; <id&gt;dm-dev</id&gt; <!-- 不设置activation,或者设置activeByDefault为false --&gt; <properties&gt; ... </properties&gt; </profile&gt; ``` ### 3. 使用Maven命令激活指定profile 在命令行中,通过`-P`参数指定激活的profile,多个profile用逗号分隔: ```bash mvn clean install -P dev,dm-dev ``` ### 4. 验证profile是否生效 在Maven命令中加入`help:active-profiles`目标,可以查看当前激活的profile: ```bash mvn help:active-profiles -P dev,dm-dev ``` ### 5. 检查ID唯一性 确保每个profile的id是唯一的。如果两个profile的id相同,则后定义的会覆盖先定义的。 ### 6. 检查整个pom.xml文件结构 确保`<profiles&gt;`标签是`<project&gt;`的直接子元素。结构如下: ```xml <project&gt; ... <profiles&gt; <profile&gt;...</profile&gt; <profile&gt;...</profile&gt; </profiles&gt; ... </project&gt; ``` ### 示例:正确的多profile配置 ```xml <project&gt; ... <profiles&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; <profile.name&gt;dev</profile.name&gt; </properties&gt; </profile&gt; <profile&gt; <id&gt;dm-dev</id&gt; <!-- 不设置默认激活 --&gt; <properties&gt; <profile.name&gt;dm-dev</profile.name&gt; </properties&gt; </profile&gt; </profiles&gt; ... </project&gt; ``` ### 总结 问题很可能出在两个profile都设置了`<activeByDefault&gt;true</activeByDefault&gt;`,导致冲突。建议移除其中一个profile的默认激活设置,然后通过命令行参数`-P`来激活需要的profile。 §§相关问题§§: 1. Maven的profile有哪些激活方式? 2. 如何在Maven中同时激活多个profile? 3. 如何在Spring Boot项目中根据不同的Maven profile加载不同的配置文件? 4. 如何通过环境变量激活Maven profile?</think&gt;根据您提供的 Maven 配置片段,问题出在**多个 `<profile&gt;` 都设置了 `<activeByDefault&gt;true</activeByDefault&gt;`**。Maven 不允许同时有多个默认激活的 profile,这会导致配置冲突。 ### 问题分析 1. **冲突原因**: - 第一个 profile (id=`dev`) 设置了 `<activeByDefault&gt;true</activeByDefault&gt;` - 第二个 profile (id=`dm-dev`) 也设置了 `<activeByDefault&gt;true</activeByDefault&gt;` - Maven 不允许同时存在多个默认激活的 profile 2. **错误表现**: - 当您取消第二个 profile 的注释时,Maven 无法确定哪个 profile 应该作为默认激活 - 可能导致: - 构建失败 - 资源过滤不生效(`@profile.name@` 未被替换) - 应用启动时读取错误配置 ### 解决方案 #### 方法 1:只保留一个默认激活的 profile(推荐) ```xml <profiles&gt; <!-- 开发环境(默认激活) --&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; <profile.name&gt;dev</profile.name&gt; <!-- 其他配置 --&gt; </properties&gt; </profile&gt; <!-- 达梦开发环境(不设默认激活) --&gt; <profile&gt; <id&gt;dm-dev</id&gt; <!-- 移除了 activeByDefault --&gt; <properties&gt; <profile.name&gt;dm-dev</profile.name&gt; <!-- 其他配置 --&gt; </properties&gt; </profile&gt; </profiles&gt; ``` #### 方法 2:使用互斥激活条件 ```xml <profiles&gt; <!-- 普通开发环境 --&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <!-- 当没有指定 -P 参数时激活 --&gt; <property&gt; <name&gt;!dm</name&gt; </property&gt; </activation&gt; <properties&gt; <profile.name&gt;dev</profile.name&gt; </properties&gt; </profile&gt; <!-- 达梦开发环境 --&gt; <profile&gt; <id&gt;dm-dev</id&gt; <activation&gt; <!-- 当指定 -Ddm=true 时激活 --&gt; <property&gt; <name&gt;dm</name&gt; <value&gt;true</value&gt; </property&gt; </activation&gt; <properties&gt; <profile.name&gt;dm-dev</profile.name&gt; </properties&gt; </profile&gt; </profiles&gt; ``` ### 使用方式 1. **默认构建**(使用 dev 配置): ```bash mvn clean install ``` 2. **构建达梦环境**: ```bash mvn clean install -Ddm=true ``` 3. **显式指定 profile**: ```bash mvn clean install -P dm-dev ``` ### 完整配置示例 ```xml <profiles&gt; <!-- 开发环境(默认激活) --&gt; <profile&gt; <id&gt;dev</id&gt; <activation&gt; <activeByDefault&gt;true</activeByDefault&gt; </activation&gt; <properties&gt; <profile.name&gt;dev</profile.name&gt; <prefix.name&gt;jeecg</prefix.name&gt; <config.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</config.server-addr&gt; <config.namespace/&gt; <config.group&gt;DEFAULT_GROUP</config.group&gt; <discovery.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</discovery.server-addr&gt; </properties&gt; </profile&gt; <!-- 达梦开发环境 --&gt; <profile&gt; <id&gt;dm-dev</id&gt; <properties&gt; <profile.name&gt;dm-dev</profile.name&gt; <prefix.name&gt;jeecg-dm</prefix.name&gt; <config.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</config.server-addr&gt; <config.namespace&gt;dm-namespace</config.namespace&gt; <config.group&gt;DM_GROUP</config.group&gt; <discovery.server-addr&gt;192.168.2.236:8848,192.168.2.190:8848,192.168.2.179:8848</discovery.server-addr&gt; </properties&gt; </profile&gt; </profiles&gt; ``` ### 额外建议 1. **资源过滤配置**: 确保在 `<build&gt;` 中启用资源过滤: ```xml <build&gt; <resources&gt; <resource&gt; <directory&gt;src/main/resources</directory&gt; <filtering&gt;true</filtering&gt; <includes&gt; <include&gt;**/*.yml</include&gt; <include&gt;**/*.properties</include&gt; </includes&gt; </resource&gt; </resources&gt; </build&gt; ``` 2. **验证配置**: 使用以下命令检查激活的 profile: ```bash mvn help:active-profiles ``` 3. **IDE 配置**: 在 IntelliJ IDEA 中: - 打开 Maven 工具窗口 - 在 Profiles 部分勾选需要激活的 profile - 确保取消勾选 "Skip Tests" 以验证过滤是否生效
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值