pom.xml中resouces标签

pom.xml中resouces标签

resourcesmaven在编译项目时将资源文件或者额外的文件赋值到输出目录(target/classes)中。通常包括配置文件,属性文件,模板文件,jar包等。

resouces中可以包含resouce。也就是可以自定义的配置多个资源配置。

directory

使用<directory/>元素指定项目中资源文件所在的目录。

默认的资源目录是src/main/resources

<resources>
    <resource>
        <directory>src/main/resources</directory>
    </resource>
</resources>

filtering

是否开启资源过滤。过滤会替换文件中的变量,例如${project.version}。默认为false

可以参考maven资源过滤补充部分

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>

targetPath

指定资源文件在构建输出目录中的路径。默认是在编译后的根目录${pom.build.outputDirectory}也就是target/classes。可以自定义输出目录的路径。

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <targetPath>/</targetPath>
    </resource>
</resources>

includes

可以指定要包含那些资源文件。默认是全部包含**/*。这里采用路径匹配的ant

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <targetPath>/</targetPath>
        <includes>
        	<include>**/*.properties</include>
        </includes>
    </resource>
</resources>

excludes

可以指定要排除那些资源文件。默认不排除。这里采用路径匹配的antincludes一致。通常一些模板文件或者字体文件等可以指定让他不开启资源过滤。

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <targetPath>/</targetPath>
        <includes>
        	<include>**/*</include>
        </includes>
        <excludes>
            <exclude>**/*.xlsx</exclude>
            <exclude>**/*.pdf</exclude>
        </excludes>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <targetPath>/</targetPath>
        <includes>
            <include>**/*.xlsx</include>
        	<include>**/*.pdf</include> 
        </includes>
    </resource>
</resources>
  • 8
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
很高兴回答您的问题。根据提供的图片,这是一段Python代码演示了如何使用Pygame库创建一个简单的游戏窗口,其包括一个代码小船。以下是代码解释和演示: 1. 引用: 首先需要安装Pygame库,可以使用pip命令进行安装(如果已经安装,可以跳过此步骤)[^1]。 2. 引用: 导入Pygame库,然后初始化Pygame,并设置游戏窗口的大小和标题[^2]。 ```python import pygame pygame.init() # 初始化Pygame # 创建游戏窗口,设置窗口大小和标题 screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Code Boat") ``` 3. 引用: 加载代码小船图像,并将其放置在游戏窗口的央位置[^3]。 ```python # 加载代码小船图像 boat = pygame.image.load("codeboat.png") # 获取代码小船图像矩形的宽度和高度,并计算其心位置 boat_rect = boat.get_rect() boat_rect.centerx = screen.get_rect().centerx boat_rect.centery = screen.get_rect().centery ``` 4. 引用: 通过不断循环,绘制游戏窗口并更新代码小船的位置,以模拟代码小船的移动[^4]。 ```python # 不断循环,直到用户关闭游戏窗口 while True: # 处理游戏事件 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() # 绘制游戏窗口 screen.fill((255, 255, 255)) # 设置背景颜色为白色 screen.blit(boat, boat_rect) # 绘制代码小船图像 # 更新代码小船位置 boat_rect.move_ip(1, 0) # 刷新游戏窗口 pygame.display.flip() ``` 演示效果如下所示: <img src="../resouces/image/codeboat.gif" alt="代码小船演示" width="400" height="300">

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

假女吖☌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值